Timeline Control

April 17, 2007

Assumed Knowledge: Basic creation of symbols and general Flash interface
Concepts Covered: Controlling the movement in the Flash timeline through buttons

Open up Flash and make 2 buttons, one which is labeled Play and the other one Pause. On a new layer create some sort of animation that lasts for at least 10 frames. Extend the bottom layers length in the timeline so that it is the same as the animation.

Add the following code to the Play button:

on (release){
play();
}

And add this code to the Pause button.

on (release){
stop();
}

Let?’s look at some of the code. on (release) means that once the button is released. The { finishes the statement what follows it on the next line tells the program what will happen once the button is released. play() makes the program play the animation in the timeline and stop() stops the animation in the timeline. The ; ends the command. The final { closes off the code.

Now when you test your movie you can click Pause to Pause the animation and Play to continue it.

How would you make the program stop at the beginning therefore prompting the user to press Play to begin? Simple. Place

Stop();

in the first frame. This will stop the program automatically.

You don?’t need to use release to make the button do the code. You can use other conditions such as press.

This type of timeline control is probably the most important Flash code that you?’ll ever use. So make sure that you know how to use it. It also works well in animation pieces with a simple user interface.

Downloadable Source Files

If you enjoyed this post, then make sure you subscribe to my RSS Feed

Tags: , , ,
Posted in Tutorials |



Related Entries




No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Have you checked out my gaming personal blog yet? No! Then take a squiz: