Solved

DIFFICULT *Menubar MX2004 Component*

Posted on 2004-10-21
141 Views
Last Modified: 2010-04-03
0
Question by:gmailrules
    10 Comments
     
    LVL 6

    Expert Comment

    by:nishasrilankan
    here is the working downloadable example.
    http://philflash.inway.fr/menubar/menubar.html
    0
     
    LVL 1

    Author Comment

    by:gmailrules
    no, every one has a submenu.  the problem is getting an event listener to work with the menu items rather than the menu submenu items
    0
     
    LVL 6

    Expert Comment

    by:nishasrilankan
    With Menu component you cannot attach Event Handlers...that can be only achieved with MenuBarItem Class....MenuBarItem class has six event handlers..onPress, onRelease, onRollOver, onRollOut, onDragOver and onDragOut...
    0
     
    LVL 1

    Author Comment

    by:gmailrules
    i think the menu component has a focusin even handler and menubaritem has a change handler
    0
     
    LVL 1

    Author Comment

    by:gmailrules
    how would i modify the class to add the change event handler to the menu buttons then?
    0
     
    LVL 6

    Expert Comment

    by:nishasrilankan
    Sorry...Menu has following event handlers..
    Event summary for the Menu class

    Menu.change
     Broadcast when a user causes a change in a menu.
     
    Menu.menuHide
     Broadcast when a menu closes.
     
    Menu.menuShow
     Broadcast when a menu opens.
     
    Menu.rollOut
     Broadcast when the pointer rolls off an item.
     
    Menu.rollOver
     Broadcast when the pointer rolls over an item.
     


    ///Actually Change event handler is already there
    0
     
    LVL 1

    Author Comment

    by:gmailrules
    yeah but i cant get it to work, and from what i can tell from searches other people are having the prob as well
    0
     
    LVL 6

    Expert Comment

    by:nishasrilankan
    Sorry...I dont think that can be implemented..
    0
     
    LVL 27

    Accepted Solution

    by:
    *aware: hack* :)

    var listener:Object = new Object();
    listener.change = function(evt:Object):Void
    {
         trace(evt.menuItem.parentNode.attributes.label);
    };

    var menu:mx.controls.Menu = menu_mc.addMenu("asia");
    menu.__activator.oldOnPress = menu.__activator.onPress;
    menu.__activator.onPress = function()
    {
          this.oldOnPress();
          trace("MENU 1");
    };
    menu.addEventListener("change", listener);
    menu.addMenuItem("india");
    menu.addMenuItem("china");
    menu.addMenuItem("pakistan");

    var menu:mx.controls.Menu = menu_mc.addMenu("europe");
    menu.__activator.oldOnPress = menu.__activator.onPress;
    menu.__activator.onPress = function()
    {
          this.oldOnPress();
          trace("MENU 2");
    };
    menu.addEventListener("change", listener);
    menu.addMenuItem("denmark");
    menu.addMenuItem("britain");
    menu.addMenuItem("spain");
    0
     
    LVL 1

    Author Comment

    by:gmailrules
    Sorry I took so long to get back to this question.  Thanks a lot for the anwser :D
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
    I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user how to how to record live broadcast.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now