Description
Method; changes the
attribute of the item to the state specified by the
selected
select
parameter. If this call results in a change of state, the item is redrawn with the new state. This
is only meaningful for items whose
attribute is set to
or
, because it
type
"radio"
"check"
causes their dot or check to appear or disappear. If you call this method on an item whose type
is
or
, it has no effect.
"normal"
"separator"
Example
The following example creates a menu with two menu items, the second of which is a check
box menu item. The example calls the
method to put the check
setMenuItemSelected()
box menu item in a selected state.
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();
// 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({type:"check", label:"2nd Item"})
// Create the Menu object.
var my_menu:Menu = Menu.createMenu(this, menuDP_obj);
var myItem = my_menu.getMenuItemAt(1);
my_menu.setMenuItemSelected(myItem, true);
// Show and position the menu.
my_menu.show(100, 20);
Menu.setMenuItemSelected()
931
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers