Flyout Menu Problems...

  • kevsterb007
  • Graduate
  • Graduate
  • kevsterb007
  • Posts: 145

Post 3+ Months Ago

I'm making a flyout menu (like DHTML) in flash. Using
Code: [ Select ]
onClipEvent (enterFrame) {
    oldPos = _x;
    menuLen = _root.menu2._width ;
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
        direction = 1;
        newPos = oldPos+(direction*30);
        if (_root.menu2.top.motion == "on" and newPos< 232) {
            setProperty(this, _x, newPos);
        }
    } else {
        direction = -1;
        newPos = oldPos+(direction*30);
        if (_root.menu2.top.motion == "on" and newPos>= 60) {
            setProperty(this, _x, newPos);
        }
    }
}
  1. onClipEvent (enterFrame) {
  2.     oldPos = _x;
  3.     menuLen = _root.menu2._width ;
  4.     if (this.hitTest(_root._xmouse, _root._ymouse)) {
  5.         direction = 1;
  6.         newPos = oldPos+(direction*30);
  7.         if (_root.menu2.top.motion == "on" and newPos< 232) {
  8.             setProperty(this, _x, newPos);
  9.         }
  10.     } else {
  11.         direction = -1;
  12.         newPos = oldPos+(direction*30);
  13.         if (_root.menu2.top.motion == "on" and newPos>= 60) {
  14.             setProperty(this, _x, newPos);
  15.         }
  16.     }
  17. }


This works Great, except for one problem...
The menu is vertical.

Looks like this:

Home
Productions>> |Bla|
Contact |Bla|
Help -----

This is the layout of my menu. When you hover over "Productions" the "Bla" menu Flys out from "Productions" (the bla are buttons)
This works fine, the "Bla" sub menu flys out fine. Now, logicly when you take te mouse off the sub menu it goes back in. EXCEPT for when you go directly below the productions menu to "contact".
Why? Because the Sub menu is a Movie clip that is the size of the sub menu, productions and contact.
Can I make some sort of "Hit area" or is there a better way to do it?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

When I make flyout menus, I usually use the method you used with the hit-test, but I don't usually re-position another clip (sometimes I have to if its dynamic... but thats another story), instead what I do is have the button be a movieclip symbol.

This movieclip symbol contains the tweened animation of the menu sliding in and out.

If the hitTest of the mouse is true, I run a nextFrame(), if it's false I run a prevFrame().

This way, when the mouse is over the button the panel slides in (or animated in however, it's customizable since it's a tween), and when the mouse is out, it plays out in reverse. And since the animation exists all in the same clip, you don't have issues with rolling away from the original button. Not to mention, since it's a hitTest there are no issues with clickable buttons within the clip.

Code: [ Select ]
onClipEvent(enterFrame){
if (this.hitTest(_root._xmouse, _root._ymouse, false)){
this.nextFrame();
} else {
this.prevFrame();
}
}
  1. onClipEvent(enterFrame){
  2. if (this.hitTest(_root._xmouse, _root._ymouse, false)){
  3. this.nextFrame();
  4. } else {
  5. this.prevFrame();
  6. }
  7. }
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

After re-reading that, I explained that horribly, so hopefully this over-simplified example coupled with the above explanation will help...


http://www.lostinbeta.com/experimental/ ... nuEasy.fla
  • kevsterb007
  • Graduate
  • Graduate
  • kevsterb007
  • Posts: 145

Post 3+ Months Ago

This is great! One last prob with this... When the sub menu is out and you hover over "Contact" it does not go back in. (I still don't understand action script)
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

My guess is you are putting all the buttons in the same clip and hitTesting that clip... since they all exist in the same clip its always being read that the mouse is over and your menu isn't going back.

But I don't know how you set it up so I can't really accurately troubleshoot the situation.
  • kevsterb007
  • Graduate
  • Graduate
  • kevsterb007
  • Posts: 145

Post 3+ Months Ago

I'll post again later once I get this sie up... Thanks for the help!

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.