Add custom right-click menu code in FLASH

Source: Internet
Author: User
Tags bind control characters function prototype

The previous as2.0 writing method is shared with you.

The code is as follows: Copy code

Function gotoinlookme (){
GetURL ('http: // hi.baidu.com/inlookme', '_ blank ');
}
Var mymenu: ContextMenu = new ContextMenu (); // you need to add the ContextMenu type to the defined mymenu, or no code prompt will appear later.
Mymenu. hideBuiltInItems (); // hide the default menu, but "settings" and "about" cannot be hidden.
// New ContextMenuItem (caption, callbackFunction, [separatorBefore, [enabled, [visible]) complete function prototype
Mymenu. customItems. push (new ContextMenuItem ("design support-inlookme", gotoinlookme); // add the defined entries to the menu
_ Root. menu = mymenu; // bind to the home scene. You can also bind a menu to a button or other component.


For more information about how to use as3.0, see here.

The code is as follows: Copy code

Package
{
Import flash. display. Sprite;
Import flash. events. Event;
Import flash. ui. ContextMenu;
Import flash. ui. ContextMenuItem;

/**
* Hide the Flash context menu instance
* @ Author fising <fising@qq.com>
*/
Public class Main extends Sprite
 {

Public function Main (): void
  {
If (stage) init ();
Else addEventListener (Event. ADDED_TO_STAGE, init );
  }

Private function init (e: Event = null): void
  {
RemoveEventListener (Event. ADDED_TO_STAGE, init );

// Stage. Showdefaconcontextmenu = false;

Var cmitem: ContextMenuItem = new ContextMenuItem ('Madhouse Inc. Ver 100', true );

Var cm: ContextMenu = new ContextMenu ();
Cm. hideBuiltInItems ();
Cm. customItems. push (cmitem );
This. contextMenu = cm;
  }
 }
}

Note:

The custom menu item appears at the top of the context menu and is located above all built-in menu items. Custom menu items and built-in menu items are always separated by separators. You cannot add more than 15 custom menu items to the context menu. Each menu item must contain at least one visible character. Control characters, line breaks, and other blank characters are ignored. The length of all menu items cannot exceed 100 characters. If a menu item is the same as any built-in menu item or other custom menu items, this menu item is ignored no matter whether the matching menu item is visible or not. When comparing menu items, uppercase and lowercase letters, punctuation marks, and spaces are ignored. The following words cannot appear in custom menu items: Macromedia, Flash Player, and settings.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.