Dowload PDF in Full Site Email the Author

The Expand/Collapse Arrow
Let’s move on to the arrow (clip.arrow) at the right of the menu bar. When the user {Clicks} on the arrow (or triangle, I’ll just call it an arrow) we want three things to occur. First, we need the arrow to point either downward or upward, depending on its current orientation. Second, we want the first set of menu items to appear when pressed and pointing downward, and disappear when pressed and pointing upward. Third, we want the sound Switch Small Plastic to occur as a further indication that the arrow has been {Clicked}. Since we haven’t built the first set of menu items we’ll concentrate on making the arrow turn up and down and adding the sound with ActionScript.
Because we’re going to manipulate the Instance of clip.arrow, we need to give it an Instance Name. I’ve named xc for eXpand and Collapse. That done, its a good idea to create a new Layer and place an Instance of button.empty over the Instance of clip.arrow and scale it appropriately.
Next we add the script to change the orientation of clip.arrow (Instance Name: xc):


on (press) {
xc._rotation+=180;
}


We use the rotation property of the xc Instance to add 180 degrees to its current orientation. If you haven’t seen it already, the += operator takes into account the current value being referred to in the script (in this case the rotation value of the xc Instance) and adds whatever value follows the equal (=) sign. Its equivalent to this statement:

xc._rotation=xc._rotation+180;

As you can see, the first option is the better option.
If you’re following along, test the movie or run m0004.swf. Now, each time you {Click} the arrow, it flips in the opposite direction to which it currently points.


Introduction Adding Sound to the Arrow
How the Menu will Function Building the Menu Item Clips
A Look at the Menu Generic External Scripts
Planning and Mapping Navigation Building the Submenu Clips
Building the Assets Menu Assembly: Putting the Clips Together
Sound Building and Scripting the Fly-outs
Draggable Menu Menus within Menus
Expand/Collapse Arrow