ActionScript 2.0 Components Language Reference |
|
|
|
| Menu component > MenuDataProvider.removeMenuItem() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
myMenuDataProvider.removeMenuItem()
A reference to the removed Menu item (XML node); undefined if an error occurs.
Method; removes the target item and any child nodes.
Any node or menu item in a MenuDataProvider instance can call the methods of the MenuDataProvider class.
The following example creates a menu with three menu items and, after an interval of a couple of seconds (2000 milliseconds), calls removeMenuItem() to remove the first menu item.
You first drag a Menu component to the library and then add the following code to Frame 1:
/**
Requires:
- Menu component in library
*/
import mx.controls.Menu;
// Create an XML object to act as a factory.
var my_xml:XML = new XML();
d
// The item created next does not appear in the menu.
// The createMenu() method call (below) expects to
// receive a root element whose children will become
// the items. This is just a simple way to create that
// root element and give it a convenient name.
var menuDP_obj:Object = my_xml.addMenuItem("XXXXX");
// Add the menu items.
menuDP_obj.addMenuItem({label:"1st Item"});
menuDP_obj.addMenuItem({label:"2nd Item"});
menuDP_obj.addMenuItem({label:"3rd Item"});
// Create the Menu object.
var my_menu:Menu = Menu.createMenu(this, menuDP_obj);
// Show and position the menus.
my_menu.show(100, 20);
// Call removeItem after 2000 milliseconds.
var interval_id:Number = setInterval(removeItem, 2000, my_menu);
function removeItem(the_menu:Menu):Void {
// Remove the item at position 0.
var myItem_obj:Object = menuDP_obj.getMenuItemAt(0);
myItem_obj.removeMenuItem();
clearInterval(interval_id);
}
|
|
|
|