- Preview a Working Menu
- Menu Movie Clips
- The working scripts
- The Secondary Animation
The working scripts
Now that we have reviewed the two primary timelines, let’s review the working actionscripts in more detail and then modify them to better learn how they work.
Go back to the main timeline by clicking on the Scene 1 link above the timeline (see Figure 5).
The first script we need to discuss is the stop action placed here in frame 1 of the control actions layer.
All of the important timelines in this file combine stop actions to enable the user to make a menu selection and tween animations that provide much of the menu movement. Here we have a stop action so the menu is ready for action when the page loads in the browser.
To find the scripts in the next level of the file, you can double-click the menu on the stage or double-click any of the menus in the Library. This takes you into edit mode for the selected menu (see Figure 6).
These timelines again start with a stop action. However, as you can see in Figure 6, buttons in the Window Handle layer contain scripts with an on press event handler that moves the playback head to the next frame, which is the start of the menu opening animation.
The on press event means that the menu activates when the user presses it. But many menus also activate when rolled over. This menu can easily be changed by switching to the roll over event in the Actions panel (See Figure 6).
Figure 6 Script for opening the menu when it is clicked
Try changing the trigger event to roll over and then test the menu movie. This time, the menu activates when you roll over it with the mouse. Very cool, but now you have a new problem: the menu does not close. Also, the secondary animations are not working when you roll over the buttons in the menu. Getting this menu working with a roll over event requires a more complex approach.
For now, change the event back to Press. You now need a script to close the menu. This script is located in menu button in frame 5, where the menu is fully open.
To see this script, carefully select the button in the Window Handle layer (not the text in the Window Title layer). Make sure that the Property Inspector reads Button.)
This is a very simple script, again started by the Press event, which moves the playback head to frame 1 and stops it there (see Figure 7). Notice that there is no animation involved in this procedure. However, because we animated the menu open, it gives the user the illusion that the menu animates back shut, albeit, very quickly. In fact the menu shuts instantly.
The second Window Closed label and keyframe out at frame 16 is there in case you do want to animate the menu back to the closed position. Create a tween of the closing menu and change the script just described to move to the next frame instead of to frame 1.
Figure 7 Script for moving the playback head to frame 1, thus "closing" the menu