|
Menu Assembly:
Putting the Clips Together
Next, make sure you
give the Instance of clip.m.maincategories an Instance Name, in this case
make it maincat. Were going to control this Instance with script.
Specifically, we are going to make this clip invisible by default, and
use the expand/collapse button to toggle the clips visibility. mainCat._visible=false; We are setting the Instances visible property (a property of the MovieClip Object) to false so that by default the Instance is not visible. When the user {Clicks} the expand/collapse button, the Instance (mainCat) will be made visible or invisible appropriately. Lets edit the script in button.empty. Thus far we have: on
(press) { What we need to add
is a script that checks the current status of the visible property of
the Instance (mainCat). If the mainCat Instance is not visible (which
it wont be when the movie begins and the arrow is pointing upward,
indicating collapse) then make it visible. If it is visible, then make
it invisible. if
(mainCat._visible==false)
{ First we check to
see if mainCat is currently not visible, as in: if
(mainCat._visible==false)
If this is the case
the we make it visible as in: mainCat._visible=true; If it is not the case,
if mainCat is visible then we make it invisible, as in: mainCat._visible=false; The key concept to
keep in mind is that the mainCat Instance is initially invisible. Furthermore,
the Instance of clip.arrow is initially pointing upward, which indicates
that the menu is currently collapsed, and thus we cannot see the main
categories or menu items. The moment the user {Clicks} the button, the
arrow reverses its orientation, pointing downward. Because the mainCat
Instance is not visible at this point it is made visible. When the user
{Clicks} the arrow button again the orientation of the arrow is reversed,
pointing upward, and because the mainCat Instance is visible, it is made
invisible. Simple logic that depends very much on how you set up the initial
state of the Instances were using. The script in the arrow or expand/collapse
button should now appear as follows: on
(press) { If you run the movie,
you should be able to use the expand/collapse button to make the main
categories appear and disappear. View m0008.swf
and if you like, load m0008.fla to continue
on. |