Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > ContextMenu > copy (ContextMenu.copy method) | |||
public copy() : ContextMenu
Creates a copy of the specified ContextMenu object. The copy inherits all the properties of the original menu object.
Availability: ActionScript 1.0; Flash Player 7
ContextMenu - A ContextMenu object.
This example creates a copy of the ContextMenu object named my_cm whose built-in menu items are hidden, and adds a menu item with the text "Save...". It then creates a copy of my_cm and assigns it to the variable clone_cm, which inherits all the properties of the original menu.
var my_cm:ContextMenu = new ContextMenu();
my_cm.hideBuiltInItems();
var menuItem_cmi:ContextMenuItem = new ContextMenuItem("Save...", saveHandler);
my_cm.customItems.push(menuItem_cmi);
function saveHandler(obj, menuItem) {
// saveDocument();
// custom function (not shown)
trace("something");
}
clone_cm = my_cm.copy();
this.menu = my_cm;
for (var i in clone_cm.customItems) {
trace("clone_cm-> "+clone_cm.customItems[i].caption);
}
for (var i in my_cm.customItems) {
trace("my_cm-> "+my_cm.customItems[i].caption);
}
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001551.html