After figuring out that removeMovieClip won't work on objects
with negative depth numbers, I've run into another stumbling block
in some menu generation code I'm working on.
For the most part, my menu code is complete, and functional.
However I've been trying to clean up some of the display methods to
make it a nicer and smoother interface.
When you rollover a menu item, a submenu appears. This
submenu consists of a number of items. Let's pretend we have this
MAIN MENU %26gt; SUBMENU %26gt; ITEM 1, ITEM2, ITEM 3.
ITEM 1, ITEM2, and ITEM 3 are nested in SUBMENU. For example,
the full path for ITEM 1 is _level0.mainmenu.submenu.item1.
SUBMENU itself consists of a background object and the item
objects. The items all have event handlers assigned to them.
onRollOver highlights a selection, onRollOut unhighlights the
selection, onRelease jumps to the appropriate Movie Clip.
What I would like to do is assign an onRollOut event to
SUBMENU that collapses the menu on a mouse roll out event. It
works, however, when I do this, the event handlers of the nested
ITEMs become nonfunctional.
Is it not possible for parent and child movie clips to both
have onRollOut events assigned to them? Or is there something else
I'm missing?Nested MovieClip event handlers
if parent and child movieclips both have mouse handlers the
child movieclip with not see the mouse events because the parent
will intercept them.
to remedy define handlers on the child generation or use a
hitTest() on one of the generations.Nested MovieClip event handlers
OK, that seems to have worked. I put an onEnterFrame handler
which performs a hitTest on the mouse position and bounding box of
the subMenu. Everything collapses as it should. I can't help but
feel my code could be cleaner, but it does the job.
yes, i try and avoid loops the run forever when they are only
needed occassionally.
you can do better by initiating your loop when the main menu
is rolled over and terminating the loop when your hitTest is false
and the mouse is not over item1, item2 etc.
Heh. That's exactly how I did it. Loop only starts after the
subMenu is built and the onEnterFrame deletes itself when the
results of the hitTest tell the actionscript the mouse is outside
the subMenu and menu bounding box.
then you can only do better by defining handlers on the child
generation.
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment