Menu | mouse | |-Right
Original tutorial, reproduced please indicate the source: Web Teaching Network
The right mouse button has always been a popular topic, from the beginning of the Flash MX has been able to customize the menu of the right mouse button, here will be some related objects and the use of relevant information to introduce to everyone.
Right-click Menu control mainly uses two objects:
The ContextMenu object is used to produce a new menu array
The Contextmenuitem object is used to produce a new menu item
For its specific use we first look at a specific effect:
< param name= "wmode" value= "window" >
For its implementation, I put the main code for everyone to explain:
My_menu = new ContextMenu ();
Declare a new Menu object
My_menu.hidebuiltinitems ();
Open the current right-click menu (Of course, set menu and version information is temporarily unable to open)
var dance = new Contextmenuitem ("Dance Baby!!!", dodance) My_menu.customItems.push (dance);
Set a variable create a new submenu item named "Dance Baby!!!", the response function is dodance
My_menu.customItems.push (New Contextmenuitem ("menu Two", do_menu_02, True);
Create a new submenu named "Menu Two" and add a divider line
my_menu.customitems[0].enabled = false;
Set the first menu item to be unavailable ("menu One" is not available, gray display)
my_menu.customitems[1].visible = flase;
Set the second menu item not displayed ("Two" is not displayed, which is equivalent to a temporary absence of this menu)
function Dodance () {
McLetters.dancer.gotoAndPlay (2);
}
"Dance Baby!!!" Specific content of response function
function do_menu_02 (Obj,item)
{
Response function Specific content of "menu two"
}
.................
Mcletters.menu = My_menu;
Bind the currently defined menu to the right key menu of the movie clip
_root.menu = My_menu;
Bind the currently defined menu to the right-click menu of the main scene
In the example above, My_menu is a new menu object, and My_menu.customitems is a property in the Menu object, which is actually an array of objects, starting with subscript 0, which in turn represents each menu item that is defined.
The Contextmenuitem object is defined with five parameters, and the latter three are optional Boolean objects.
var my_menu = new Contextmenuitem (menu name, response function name, whether to add separator line, available, whether to display)
For a defined menu, you can bind to _root, or you can bind to a button, movie, or dynamic text object. The concrete application and the operation everybody may try.
In giving you two examples: 1. menu item Dynamic Change:
2. Examples of slightly more complex menus:
< param name= "allowscriptaccess" value= "Always" >
finally provide to everyone a compression package , download to their own research it!