Copy link to clipboard
Copied
Hello,
I'm used to working with the timeline and don't often go into the actionscript side of things.
I've created a 60 second animation of an hourglass timer counting down, and next to it, is a card showing a word. I need this whole animation to play when you hit a 'start game' button and also I need the word on the card to be a random word. All of the words are saved as separate vector files for now.
What is the best way to manage this on the timeline, and what would be the code to make a random image appear?
The only discussions I've found on this are for memory games and they're over complex for what I need!
I just thought I'd put the answer incase anyone else needs help with this.
In the end I added each image as an individual frame on the same layer within a movie clip and added a stop(); action to each frame.
I added this line of code to the key frame with the movieclip on the timeline:
this.MovieClipName.gotoAndPlay(Math.round(Math.random()* 4)); //change 4 to the number of frames you have in the movieclip
Works great so far - I'll let you know if it throws up extra problems
Copy link to clipboard
Copied
make your words into movieclips and place them all on-stage and assign instance names for them all. you can then use the visible property to select one to make visible.
if you name them judiciously (eg, mc0,m1,...,mcN), you'll save yourself some coding effort.
Copy link to clipboard
Copied
Thanks for the help,
how can I randomise which one is visible?
Copy link to clipboard
Copied
I just thought I'd put the answer incase anyone else needs help with this.
In the end I added each image as an individual frame on the same layer within a movie clip and added a stop(); action to each frame.
I added this line of code to the key frame with the movieclip on the timeline:
this.MovieClipName.gotoAndPlay(Math.round(Math.random()* 4)); //change 4 to the number of frames you have in the movieclip
Works great so far - I'll let you know if it throws up extra problems