1 person found this helpful
Do you mean to say that you have an image for each word? I usually swap images.
For text, I use arrays all the time and it works well.
You can also use a json file.
See tutorial here: http://www.gotoandlearn.com/play.php?id=168
Hey, thanks for replying.
Yes I have an image for each word and I'm using the array to load them randomly using this:
var words=new Array()
var randomWord = sym.createChildSymbol(words[whichWord], "wordWrapper")
Only now it's got 200 odd entries it seems a bit wrong to have it all sat on a .click event ..
I think an external file is the way to go, I'll have a look at that tut' tomorrow, thanks
If you're pushing 200 objects in to an array, you probably want to use a "for" loop.
Alternately, if you're loading an image randomly, and they're all named sequentially, you can try something like this:
var wordCount = 200;
var imageIDToLoad = Math.floor(Math.random()*wordCount);// choose random num
var subString = 'images/word'+imageIDToLoad+'.png';// added this var to work around double quotes
var imageURL = "url("+subString+")";// create URL based on random num ID and subString
var randomWord = sym.createChildSymbol(imageURL, "wordWrapper");
That's neat, I did try something similar because yes, the images are sequentially named, I couldn't quite figure out how to combine the variable into the image url name though I thought there was a way, thank you. I think I'll probably go for this method as although the arrays are getting quite large the device itself is relatively simple so keeping it compact and contained works well for me.
Thanks both again for your replies, very much appreciated!