Actionscript jump to random frame


In this Macromedia Flash tutorial I will show you how to make a simple actionscript code to jump to a random frame in the timeline.


1.
In the layers panel name the layer we are working with button_layer.
In the timeline right click at frame 5 and create a new keyframe.

Now make graphic for a button, right click and convert it to a movie clip.

Photoshop Tutorial thumb picture


2.
Now make a new layer in this at frame 1 type in "frame 1" with the text tool on the stage.
make a new keyframe at frame 2,3,4 and 5 and make a text graphic with the text "frame 2", "frame 3", "frame 4" and "frame 5"

Photoshop Tutorial thumb picture


3.
Now go to frame 1, select the button and go to the actionscript panel.

4.
Type in the following code in the actionscript panel.

on (release) {
gotoAndStop(random(5));
}

What this does it to tell flash, every time the mouse button is released on the graphic button then flash will jump to a random frame between 1 and 5 and then stop.

0tutor.com rss feed