|
The Expand/Collapse
Arrow
Lets move on
to the arrow (clip.arrow) at the right of the menu bar. When the user
{Clicks} on the arrow (or triangle, Ill 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 havent built the first set of menu items well concentrate
on making the arrow turn up and down and adding the sound with ActionScript.
Because were going to manipulate the Instance of clip.arrow, we
need to give it an Instance Name. Ive 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 havent 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 youre 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.
|