Add custom right-click menu code in FLASH

Source: Internet
Author: User
Tags 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: //', '_ 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

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

* Hide the Flash context menu instance
* @ Author fising <>
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;


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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.