Results 1 to 5 of 5

Thread: Need some programing advice.

  1. #1
    Goron goron Kumagoro's Avatar
    Join Date
    Mar 2004
    Posts
    3,147
    Thanks
    37
    Thanked
    170 times in 139 posts

    Need some programing advice.

    A program I wrote uses arrays to store images which because there are a
    few hundred of them takes sometime to load.

    The program basically displays an image and you push a button to say what
    it is. It displays them randomly and to select an image the random numbers
    are used to find a particular image in the array.

    My question is, what other ways can I store about 300 images which would
    be much quicker to load.

    I used javascipt and it ran in a browser, I want to make it a standalone prog
    but want it to look nice so I thought about using Flash and actionscript 2.

    Rather than use images I thought that I could use text (basically the images
    are of japanese characters.) but if the computer in question doesnt have
    japanese fonts would it work?. Or could i embed it into the program.
    The only problem I would have would be matching up what is being displayed
    with the answer. Do you think it maybe possible? How would I be able to link
    what is being displayed though....
    Last edited by Kumagoro; 01-10-2006 at 12:19 AM.

  2. #2
    Registered+
    Join Date
    Jul 2006
    Location
    Birmingham, UK
    Posts
    59
    Thanks
    4
    Thanked
    1 time in 1 post
    In flash you have the option to embed a font within the application, thus the end user does not need to have it installed on their system. Embedding a japanese font with all charachters (think they even have double byte charachters) will increase the file a fair bit... ~200KB. You can reduce this file size by only embedding a select few charachters and not the whole set.

    What you would most probably need to do is create some form of data structure to do exactly what you want and use an Array of instances of your data structure. Alternatively, you could take the easy route if this is a small project... and use an Array of Objects and simply set the properties of the Object... i.e.

    Code:
    //Array to hold your japanese charachter pics
    var arrayOfCharPics = new Array();
    
    //create a new charachter pic object to hold a pic's charachter and options
    var newCharPic = new Object();
    
    //set the charachter pic data
    newCharPic.charValue = 'a'; // set the japanese charachter here.. might need to use chr('ascii value') 
    newCharPic.option1 = "Your first option";
    newCharPic.option2 = "Your second option";
    newCharPic.option3 = "Your third option";
    newCharPic.option4 = "Your forth option";
    
    //add the new charachter pic to your array
    arrayOfCharPics.push(newCharPic);
    
    //... continue with more newCharPic's...
    That should give you a vague idea of what I mean... however, I might not have the correct understanding of what you want to do... so be weary of that.

    MdSalih

  3. #3
    Goron goron Kumagoro's Avatar
    Join Date
    Mar 2004
    Posts
    3,147
    Thanks
    37
    Thanked
    170 times in 139 posts
    Thanks for the reply.

    Knowing that I can embed a font, and more so that I could limit it to certain characters, is very helpful.

    Problem is im not a programmer and I dont know the best way to do things
    or if there are alternatives. I need pointing in the right direction about things
    to look up and read about.

    My program in javascript (opertation code is 35000 characters with no spaces
    and works out at about 3500 lines) of course there are some blank lines too.

    The GUI is about 105,000 characters and 3500 lines.

    Thats not very accurate as it was messured using word. But even halved
    thats a lot of code for me seeing as its bascially the first programme I have
    written properly off my own back.
    -
    This is basically how my Javascript program works

    a character appears.
    you press a button to say what it is.
    it tells you if its correct or not
    if you get it right it shows another.

    So its pretty simple, but I added stuff like if you get it wrong a few times
    it will tell you the answer, it wont repeat the same char for at least 3 turns
    things like that.

    Because there are about 500 characters/images or more, the 'for' loops to
    load up the array with images takes several seconds. Its not a massive
    problem but it would be nice if it worked better.

    To be honest I wrote this a few years back and now I cant remember or
    even understand how it works hahahaha. I dont even know what questions
    I should be asking.

    I just wonder if there is a way so that the images dont have to be loaded into
    this array and when the program is run the thing is already formed and filled.

    Sorry that its so mixed up but that is how i feel.

  4. #4
    Registered+
    Join Date
    Jul 2006
    Location
    Birmingham, UK
    Posts
    59
    Thanks
    4
    Thanked
    1 time in 1 post
    Well if you're using a font, all you need to do is keep a record of the charachters you want to display - this will essentially be a list of numbers or charachters (single letters).

    What would be a wise option, is to create an XML file with the charachter or ascii value of the charachter (might be needed for double byte chars).. and then a set of questions for each... and simply parse that in flash... that sholuld be quite straight forward after going through a couple of tutorials.

    Not fully sure of all the intricacies of your application, however from what you've mentioned I'd say it'd take < 1000 lines to code up something like that in actionscript.

    MdSalih

  5. #5
    Goron goron Kumagoro's Avatar
    Join Date
    Mar 2004
    Posts
    3,147
    Thanks
    37
    Thanked
    170 times in 139 posts
    Thanks again for the reply,

    I reckon im just going to have to learn by doing it like I did last time.
    Hopefully I will be able to use a font and that will cure the size of the program
    and how long it takes to load.

    Again thanks for the help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Business advice required
    By Tobeman in forum General Discussion
    Replies: 17
    Last Post: 22-06-2006, 03:32 PM
  2. Some advice on a new digi cam ...
    By iChimp in forum Consumer Electronics
    Replies: 13
    Last Post: 10-12-2005, 12:07 PM
  3. Advice, advice, advice - please! =]
    By ytrebil in forum PC Hardware and Components
    Replies: 0
    Last Post: 01-06-2005, 03:04 PM
  4. Terror Advice Leaflet Coming to Your Letter Box
    By XTR in forum General Discussion
    Replies: 16
    Last Post: 28-07-2004, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •