Adding a Second Scene
Flash movies may be subdivided into scenes. This lets you group action and interaction among several separate timelines within the main movie. You'll need this technique for Assignment 2, in which action must pause or repeat until the viewer clicks at some point in the window.
Adding a second scene to your movie is simple: just go to the Insert menu and select Scene. In the editor you will now see a fresh timeline which belongs to Scene 2 of your movie.
Once you've created a second scene, you'll need to exercise some control over it. If you preview your movie at this point (by selecting Control>Test Movie), the timeline for each scene will play all the way through. If you wanted this, you would probably just have tacked the contents of Scene 2 onto the timeline for Scene 1.
Here's the answer. Call up Scene 1 and move to the final frame of its timeline. At this point in the timeline, look for a keyframe. If you can't find one, insert one in some layer. Right-click on this keyframe and select Actions from the pop-up menu that appears. This will take you to the ActionScript editor.
In the editor, enter just this line:
stop();
Then go back and test your movie again. It should stop at the end of Scene 1.
But let's say you don't want to stop at the end of Scene 1, but rather want to repeat it endlessly until the user clicks her mouse. In that case, don't insert the stop() action on the final frame but instead write this:
gotoAndPlay(1);
Note that goto is spelled just as you see it, without a capital "t". The statement won't work if you capitalize the "t". However, the "A" in "And" and the "P" in "Play" both must be capitalized.
Controlling Access to Scene 2
The simplest control for scene transitions is a button, a special Flash Symbol that performs an action when a mouseclick occurs within it. See our textbook for more details about buttons. Here's a quick overview providing the information you need for Assignment 2.
Go to the Insert menu and select New Symbol. The Symbol Properties dialog will appear. Within the window, click the radio button under Behavior for Button. Your editing view will now show you the timeline for a button.
All buttons have four frames by default; but instead of corresponding to moments of playback, these frames correspond to button states: Up, Over, Down, and Hit. The Up state is the button's inert, untouched appearance. The Over state is assumed when the mouse passes into the button but the (physical) mouse button is not pressed. The Down state takes over when the user presses the (physical) button on her mouse. Finally, Hit defines the area of the button that is sensitive to mouseclicks.
Insert a keyframe in the Up position and build your button. Copy this keyframe and paste it into the other three frames of the button's timeline. You can edit the contents of the Over and Down states so that the appearance of the button changes to reflect user action.
Here's the crucial part. Switch from editing the button to editing Scene 1 of your movie. Add a new layer to your timeline and drag your button onto the stage in the first frame of this layer. Right-click on the button and select Actions. In the ActionScript window, type the following:
on (release) {
gotoAndPlay ("Scene 2", 1);
}
Test your movie. It should stop at the end of Scene 1 (or repeat if that's what you want). If the button is clicked, you should see Scene 2.
Examples
You'll find all these techniques present in source files for the click-through demos. The source files may be downloaded from the clickThroughDemos folder within MMShare on Crow.
