Random

How can i make my flash animation such that…it will load randomly…random in the sense that it will load at different labels of the animation whenever its loaded…

help!! :frowning:

*Originally posted by mystee *
**random in the sense that it will load at different labels of the animation whenever its loaded…
**

What do you mean? :-\ can you be more specific?

for example i have 3 labels…under each of them…there is an image…so it means there are 3 images in the clip…

How can i randomise the image whenever the animation is loaded? eg: sometimes it will load image1 first, sometimes it will load image2 first…so on…

You could store the labels in an Array object, and pull out a random label. :slight_smile:
[AS]var labels = [“label1”, “label2”, “label3”, “label4”, “etc”];
var frame = labels[Math.floor(Math.random()*labels.length)];
myMovieClip.gotoAndStop(frame);[/AS]

wow…i don’t understand your script…can explain?

actually…for my case…its not image under the label…its actually an animation…so it means…under each label…there’s diff animation playing…

Uhmm…
[AS]// frames label (no problem here, right?)
var labels = [“label1”, “label2”, “label3”, “label4”, “etc”];
/* since arrays are zero based
we need a random number between 0 and the array length minus 1
Math.floor takes care of that */
var frame = labels[Math.floor(Math.random()*labels.length)];
// send playhead of that movieclip to the random frame
myMovieClip.gotoAndStop(frame);[/AS]
Does that help at all? I’m not very good at explaining how things work… :stuck_out_tongue:

what’s math.floor? i’m still new to all this you see…=|

seems like there’s no random animation…

Originally posted by mystee
what’s math.floor? i’m still new to all this you see…=|

http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary456.html

Originally posted by mystee
seems like there’s no random animation…

Did you replace label1, label2, label3, etc. with the actual frame labels in the MovieClip?

yah…i did…no difference…no random…hmm…

Can you attach the FLA?

unfortuntely…the size doesn’tallow me to…can u show me with an example of yours?

Done. :wink:

Thanks…it’s close to what i want…

but for my case…under each label…there’s a MC…and somehow with this script…it cannot work…=(

What could be the problem here? hmm…

Could you send me the FLA to my email? I just sent you a PM with my address.

its ok! I managed to spot my mistake! THANKS ALOT!!! :slight_smile:

You’re welcome. =)

I’m curious though… what was the problem? :stuck_out_tongue: