Written by: PERLAKI / www.subfusion.co.uk
Difficulty Level: beginner Download Fla

Yet another simple, but useful tutorial! This one is to show random parts of a movie clip. I used the MC below as part of the "lives left" section of a game I made. Everytime the MC appears on the stage, it plays a random bit. Plus, there's a delay method I use to space out the animation. Click the next button below, and the dwarfs will let rip in different ways.



Fortunately there's no setSmell ("eggy"); action in Flash!

We'll make five different variations of animation, and call then randomly. On my example above I have a next button, but I'll leave that out of this to simply show how the random bit works.
Create an MC (Ctrl+F8) and on the first frame add the actions
gotoAndPlay (random ( 20 ));

From frame 15 to 20, add new keyframes. On frame 15 add the actions
gotoAndPlay (1);

On frame 16 add
gotoAndPlay ("anim1");

On frame 17 add
gotoAndPlay ("anim2");

On frame 18 add
gotoAndPlay ("anim3");

etc until frame 20.

Now then, further up the timeline, add a new keyframe and give it the label "anim1". Add some tremendously inspiring animation. Further again add another keyframe with the label "anim2", add some more animation. Keep this going to cover five animations. On my example above, I have a "stop (); " at the end of the animations, but you could have a gotoAndPlay (1); to keep the playhead moving. I have a stop on mine because it was part of a game and slowed down the whole movie because there was too much going on - something you have to bear in mind.

I have the beginning as a gotoAndPlay (random ( 20 )); so that there's only 5 times out 20 that the animation will play first time, and it will keep going around until it hits one of the gotoAndPlay ("anim?");. By doing this, it gives a more spaced out random with different timing in between each one. Hope some of you can make use of this. See ya!