Control the document with a stop() action
When you test or publish a Flash document that contains more than one scene, by default the
scenes play linearly, in the order in which they appear in the Scenes panel. You'll use a
action for Scene 1 so that the playhead in the Timeline stops at Frame 1 of Scene 1.
In the main Timeline for Scene 1, add a new layer and name it Actions.
1.
Click Frame 1 of the Actions layer. In the Script pane of the Actions panel (Window >
2.
Development Panels > Actions), type the following comment followed by the script that stops
the playhead on the frame:
// stops the playhead at Frame 1
stop();
Link a button to a scene
Now that the playhead stops at Frame 1, you'll add ActionScript that takes the user to Scene 2
upon releasing the goScene_btn instance.
•
Press Enter or Return twice and type the following comment, then write the function that
takes users to Scene 2 upon release of the goScene_btn instance:
// This script takes the user to Scene 2 when goScene_btn is released
goScene_btn.onRelease = function (){
gotoAndStop("Scene 2", 1);
};
In the script that you just typed, you used the
gotoAndStop
number. In this case, you specified Frame 1.
Add navigation to return to Scene 1
The function that you'll add to the button in Scene 2, to return the user to Scene 1, is similar to
the function that you wrote to take the user to Scene 2.
In the Scene panel, select Scene 2. In the Timeline, create a new layer and name it Actions.
1.
Select Frame 1 of the Actions layer. In the Actions panel, enter the following in the Script pane:
2.
// function takes user to Scene 1 when back_btn instance is released.
back_btn.onRelease = function (){
gotoAndStop("Scene 1", 1);
};
The only differences between this function and the function in Scene 1 are the name of the
button and the name of the scene.
In the Scene panel, select Scene 1.
3.
100
Chapter 13: Add Interactivity with ActionScript
function is a Timeline control function that lets you specify the scene and frame
method for the button object. The
onRelease()
stop()
Need help?
Do you have a question about the FLASH MX 2004-LEARNING FLASH and is the answer not in the manual?
Questions and answers