A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: ContextMenu

  1. #1
    Member
    Join Date
    Sep 2014
    Posts
    75

    ContextMenu

    Hello,

    Code:

    var menu_cm:ContextMenu = new ContextMenu();
    menu_cm.customItems.push(new ContextMenuItem("Save...", doSave));
    function doSave(menu:Object, obj:Object):Void {
    trace(" You selected the 'Save...' menu item ");
    }
    myBtn_btn.menu = menu_cm;

    with a right click on the button named: "myBtn_btn" the menu will appear with the item "Save"

    Question: I need to customize this code that whenever the user right-clicks on stage with _ymouse>300, for eaxmple,
    this "Save" item appears.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Maybe
    PHP Code:
    var menu_cm:ContextMenu = new ContextMenu(onRightClick);
    var 
    menuItemA:ContextMenuItem = new ContextMenuItem("Save..."doSave);

    function 
    doSave():Void
    {
        
    trace(" You selected the 'Save...' menu item ");
    }

    function 
    onRightClick():Void
    {
        if (
    _xmouse >= 300)
        {
            
    menu_cm.customItems = [menuItemA];
        }
        else
        {
            
    menu_cm.customItems = [];
        }
        
    trace("right clicked x:" _xmouse);
    }

    _root.menu menu_cm
    Last edited by fruitbeard; 03-30-2015 at 07:30 AM.

  3. #3
    Member
    Join Date
    Sep 2014
    Posts
    75
    thank you!

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