How to get mc name on right click??

  • hi all

    can someone plz tell me that how can i get the name or text of any mc when i right click on that? there are 2 different movieclips. both have same option in its context menu item. now can flash detect that which one is right clicked?

    thanks in advance for any support.


  • It should work then. It works for me. You'll have to screw around with it little and double check it.


  • Wicked :) Thanks, i'll report that to my superiors :p


  • Actually, the ContextMenu class has an onSelect event handler which gives you the name of the movie clip (or button or text field) that you right-clicked on. Example:

    ActionScript Code:
    var myMenu:ContextMenu = new ContextMenu();


    myMenu.hideBuiltInItems();


    myMenu.customItems = new Array(new ContextMenuItem("Hello World!", function(){}));


    myMenu.onSelect = function(dObj:Object):Void {


        trace(dObj);


    }


     


    myMC1.menu = myMenu;


    myMC2.menu = myMenu;






    thanks Canadian, but the output window is showing "undefined". but mc's instance name is "lbl1".



  • thank you all (-: its working now. The problem was that in "Publish settings" there was "AS1.0" was selected.


  • Did you change myMC1.menu = myMenu to lbl1.menu = myMenu??


    yes sure. its there. i hv just added the function for onSelect.


  • Actually, the ContextMenu class has an onSelect event handler which gives you the name of the movie clip (or button or text field) that you right-clicked on. Example:
    var myMenu:ContextMenu = new ContextMenu();
    myMenu.hideBuiltInItems();
    myMenu.customItems = new Array(new ContextMenuItem("Hello World!", function(){}));
    myMenu.onSelect = function(dObj:Object):Void {
    trace(dObj);
    }

    myMC1.menu = myMenu;
    myMC2.menu = myMenu;


  • There is currently no right click event for a movieclip. That means you will have to use hitTest to be able to extrapolate which movieclip you clicked on.

    Lookup hitTest in the help.


  • Did you change myMC1.menu = myMenu to lbl1.menu = myMenu??


  • thank you all (-: its working now. The problem was that in "Publish settings" there was "AS1.0" was selected.

    Thats what I was going to ask ;)


  • its workign in seperate movie, but when i embed this code in my movie, it returns 2 errors in onSelect function. one for "expected {" and another for "unexpected {" !!!!! when i remove "void" it runs without error but dont returns/trace the movieclip name.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about How to get mc name on right click?? , Please add it free.