A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Listeners, Target, Mouse event flow issues on a 2 level menu

  1. #1
    Join Date
    Jul 2009

    Listeners, Target, Mouse event flow issues on a 2 level menu


    I'm struggling with a 2 level menu and it needs to follow this condition:

    The "menuItem" button should be trigged with MOUSE_OVER to open its SubMenu, cause it needs to be also associated with the CLICK event.

    I'm managing the objects in the display list like this:

    ______bt_title (movieclip that contains textfield with title of the button)
    ________tabfill (each one gets redimensioned to fit subMenu size)

    My question: how should I manage the EventListeners ?

    I've done like that:

    menu_mc.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
    I should be able to MOUSE_OVER the menuItem to open the subMenu, and leave it open while I'm still able to MOUSE_OVER and CLICK the menuItem.bt_title and every other subMenuItems.

    If i do:

    menuItem.mouseChildren = false;
    then i don't have access anymore to its children.

    If i do that:

    menuItem.mouseChildren = true;
     menuItem.bt_title.mouseEnabled = false;
     menuItem.menufill.mouseEnabled = false;
     menuItem.tab.mouseEnabled = true;
    then I get the "epileptic" effect created by continuously mousing OVER and OUT the menuItem.

    What should I do ?
    Is there something to do with the capture / bubbling phase of the event flow?
    Where exactly should I place the listeners?

    I've tried a couple of things but no success!

    Thanks in advance!!

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    press the picture...
    Read this about about bubbling. That might help you.


    There is another article about separating button events.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Orlando, Florida
    So you have a menu item right , it contains , several things , most importantly , a hit area , and if it has subitems, a subitems container , with subitems in it. So inside your menuitem assign your mouse event handlers to your hit area , the hit area should be only as big as the collapsed state of the menu item. Also if the menuitem has subitems , there is no need to add a mouse out event.Now add another hit area , that is the height and width of the whole item completely expanded , assuming it has sub item to begin with. Once you mouseover your menuitem hit area , your event handler will show your subitems container.Now you should have an expanded menuitem with fulling working subitems, that wont close. So now you need to add some hit testing, bewteen the mouseX and mouseY and the defined regions of the second , expanded hit state. So after you have removed your event listener , and an enterframe event listener , and in the handler preform your hit test to see if the user is still over the menu item. If the user is not , remove the enter frame event listener , hide the container.Really you dont need the second hit state , but it might easier to visualize whats happening if its there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center