Jumping to Random Frames in Flash

Make your Flash files a little more interesting by adding a random element. Want to make you Flash files come alive with new and interesting looks or effects each time? Try mixing up the regular by adding the unpredictability of random numbers to your timeline and action.

Add this code somewhere to make your timeline jump to a different point and continue from there. (Well, to continue, it would need to be gotoAndPlay(), but you get the idea, I hope).

frame = Number(random(75))+1;

This script above sends a flash movie somewhere between frame 1 and 75. The command Random (75) produces a random number, including decimal places, between 0 and 74.999. The Number command makes sure it’s an integer, without decimals, so the +1 is needed to make it 1 to 75, instead of 0 to 74, since there is no frame 0.

My math terminology might not all be correct in describing this script, but it does work. So try it, and build on it. Use it to control movie clips, enter loops at random parts, make background element appear and disappear at different points. This little two line code can build to completely revitalize any Flash file and make your file appear to be so much more complicated with only a little bit of extra work.

Leave a Reply

19 − seven =

This site uses Akismet to reduce spam. Learn how your comment data is processed.