A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Right Click menu in as3 !!!

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    22

    Exclamation Right Click menu in as3 !!!

    hey guys how can i edit this code in order to be working in AS3 ????? i mean what do i need to change and with what ????

    Code:
    stop();
    
    function deadClick () {
    }
    
    function gotoMySite () {
    getURL("http://www.google.com", "_blank");
    }
    
    var myMenu:ContextMenu = new ContextMenu();
    myMenu.hideBuiltInItems();
    
    var copyrightNotice:ContextMenuItem = new ContextMenuItem("© 2006 KPro Digital Media", deadClick);
    var mySiteLink:ContextMenuItem = new ContextMenuItem("KPro Tutorial Center", gotoMySite);
    copyrightNotice.separatorBefore = true;
    
    myMenu.customItems.push(mySiteLink, copyrightNotice);
    
    _root.menu = myMenu;
    Last edited by lambrospower; 07-30-2007 at 09:13 AM.

  2. #2
    Junior Member
    Join Date
    Jun 2007
    Posts
    22
    hey guys i tried to make it AS3 and i don't find any error myself..and it even agrees with the livedocs..but it doesn't work when testing it....does anyone know the reason ??????

    please help me !!!!!

    stop();
    function deadClick () {
    }

    function gotoMySite () {
    var mySite:URLRequest = new URLRequest("http://www.webng.com/volleyman/");
    navigateToURL(mySite);
    }

    var myMenu:ContextMenu = new ContextMenu();
    myMenu.hideBuiltInItems();

    var copyrightNotice:ContextMenuItem = new ContextMenuItem("© 2007 V-Men");
    var mySiteLink:ContextMenuItem = new ContextMenuItem("VolleyMen Homepage");
    copyrightNotice.separatorBefore = true;

    myMenu.customItems.push(mySiteLink, copyrightNotice);

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Location
    Manhattan
    Posts
    398
    One thing you need to do is import your classes.

    Code:
    import flash.net.URLRequest;
    import flash.ui.ContextMenu;
    
    stop();
    function deadClick () {
    }
    
    function gotoMySite () {
    var mySite:URLRequest = new URLRequest("http://www.webng.com/volleyman/");
    navigateToURL(mySite);
    }
    
    var myMenu:ContextMenu = new ContextMenu();
    myMenu.hideBuiltInItems();
    
    var copyrightNotice:ContextMenuItem = new ContextMenuItem("© 2007 V-Men");
    var mySiteLink:ContextMenuItem = new ContextMenuItem("VolleyMen Homepage");
    copyrightNotice.separatorBefore = true;
    
    myMenu.customItems.push(mySiteLink, copyrightNotice);
    The flash ide would not immediately throw an error for not importing those classes but it would not work at runtime. You must import any class that you use.
    JA

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Posts
    22
    well i treid it but it doesn't work either !!! damn i can't find any code problem.......please anyone that knows

  5. #5
    Member
    Join Date
    Oct 2005
    Location
    essex
    Posts
    72
    you just need to apply the context menu you made... i.e

    this.contextMenu = myMenu;

  6. #6
    Flash Developer
    Join Date
    Jul 2008
    Location
    Scotland
    Posts
    106
    Thanks guys, I now understand how to do this now

  7. #7
    Junior Member
    Join Date
    Mar 2009
    Posts
    1
    I cant get the url request working.
    A help wuld be appreciated.

  8. #8
    Junior Member
    Join Date
    Mar 2009
    Posts
    1
    Thanks for all your help. Here is a solution to the url request issue:

    Code:
    // update context menu: 
    //		no optional built-in features as play creates a playback reader error
    // 		new copyright and home page features
    var myContextMenu = new ContextMenu();
    myContextMenu.hideBuiltInItems();
    var copyrightNotice:ContextMenuItem = new ContextMenuItem("© Copyright 2009, LectureMaker.com");
    var mySiteLink:ContextMenuItem = new ContextMenuItem("LectureMaker home page");
    copyrightNotice.separatorBefore = true;
    myContextMenu.customItems.push(mySiteLink, copyrightNotice);
    mySiteLink.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,function() { navigateToURL(new URLRequest("http://www.LectureMaker.com"), "_blank");});
    this.contextMenu = myContextMenu;

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