How to Change Between Scenes in AS3

Photos.com/AbleStock.com/Getty Images

Scenes help you organise large flash animation projects and can be reused throughout your animation project. Controlling the scene sequencing with ActionScript 3 (AS3, the Flash programming language) makes working with scenes even easier. With just a line of AS3 code you can instantly play a different scene. Using scenes in Flash is not just used to improve productivity, but as an easy way to interject commercials or interactive pauses. Because of Flash's video capabilities, you can interject a video scene for a real commercial effect or a questionnaire to find out what viewers are thinking.

Start Flash Professional. Click "Flash File (ActionScript 3.0)" from the splash window to create a new file for an AS3 Flash animation project.

Click "Scene" from the Insert menu to create a new scene. Create an animation in this scene. Click "Scene" again from the Insert menu to create another animation in this scene. Continue creating scenes for your movie in a similar fashion.

Click "Scene" from the "Other Panels" menu within the Window menu to display the Scene Panel. Note that he name of the three scenes created have been automatically named in the Scene Panel as "Scene 1," "Scene 2" and "Scene 3."

Click the "Scene 1" icon in the Screen Panel to display the contents of Scene 1 on the stage. Click "Timeline" in the Window menu to display the timeline for Scene 1. Insert a blank keyframe on the frame before the last frame on Scene 1's timeline. Position your mouse cursor over the blank keyframe you created and click your mouse button to select the keyframe.

Open up the Actions Panel and type on the first line of the ActionsScript 3 editor the code:

gotoAndPlay(1,"Scene 2");

This will instruct Flash to start playing the Scene 2 beginning at frame 1 on the Scene 2 timeline when Scene 1 reaches its last frame.

Click the "Scene 2" icon in the Screen Panel to display the contents of Scene 2 on the stage. Click "Timeline" in the Window menu to display the timeline for Scene 2. Insert a blank keyframe on the frame before the last frame on the Scene's 2 timeline. Position your mouse cursor over the blank keyframe you created and click your mouse button to select the keyframe.

Open up the Actions Panel and type on the first line of the ActionsSript editor the code:

gotoAndPlay(1,"Scene 3");

This will instruct Flash to start playing the Scene 3 beginning at frame 1 on the Scene 2 timeline when Scene 2 reaches its last frame.

Repeat the procedure for scene 3, but enter the following code in the last frame, so that your Flash animation will continually loop through scenes 1, 2 and 3 -- in that order:

gotoAndPlay(1,"Scene 1");

Most recent