| Package | km.components |
| Class | public class Menu |
| Inheritance | Menu List ScrollPane UIComponent flash.display.Sprite |
import km.components.*;
import km.skins.*;
var menu242Data:XML =
<data>
<item label='Menu 2.4.2.1' value='m2421' />
<item label='Menu 2.4.2.2' value='m2422' />
<item label='Menu 2.4.2.3' value='m2423' />
<item label='Menu 2.4.2.4' value='m2424' />
</data>;
var menuData:XML =
<data>
<item label='Menu 1' value='m1' />
<item label='Menu 2' value='m2' orientation='2' >
<item label='Menu 2.1' value='m21' />
<item label='Menu 2.2' value='m22' />
<item label='Menu 2.3' value='m23' />
<item label='Menu 2.4' value='m24' subwidth='100'>
<item label='Menu 2.4.1' value='m241' />
<item label='Menu 2.4.2' value='m242' submenu='menu242alias' />
<item label='Menu 2.4.3' value='m243' />
</item>
<item label='Menu 2.5' value ='m25' />
</item>
<item label='' disabled='true' />
<item label='Menu 3' value ='m3' />
<item label='Menu 4' value ='m4' />
</data>;
var menu242:Menu = new Menu();
Menu.register(menu242, 'menu242alias'); // register menu alias
var menu:Menu = new Menu(Menu.HORIZONTAL_CONDENSED);
ScriptedSkin.applyTo(menu242, menu);
menu242.listItem.setSize(100,30);
menu242.setDataXML(menu242Data);
menu.setDataXML(menuData);
addChild(menu);
function onMenu(item:Object):void {
trace (item.value);
}
menu.onMenu = onMenu;
| Property | Defined by | ||
|---|---|---|---|
![]() | background : Image
>> Reference to the background image.
| ScrollPane | |
![]() | duotone : Array The duotone property can be used to convert the colors of the component into duotone.
| UIComponent | |
![]() | enabled : Boolean Specifies if the component is enabled.
If a component is disabled, it will be turned into grayscale and become partly transparent. | UIComponent | |
![]() | htmlLabels : Boolean Gets or sets a Boolean value indicating if item labels should be displayed as html text or plain text.
| List | |
![]() | iconField : String Gets or sets the name of the field that contains the item label icon.
| List | |
![]() | labelField : String Gets or sets the name of the field that contains the item label text.
| List | |
| lastClicked : Object [read-only] Gets the last item that was clicked.
| Menu | ||
![]() | length : uint Gets the number of items in the list.
| List | |
![]() | listItem : ListItem >> Reference to the default list item.
| List | |
![]() | margin : int The margin between the bounding box of the background and the sub components inside.
| ScrollPane | |
![]() | onChange : Function onChange handler.
| List | |
| onMenu : Function onMenu handler.
| Menu | ||
| orientation : int [read-only] Gets the orientation of the menu.
| Menu | ||
![]() | toolTip : String Text to use as toolTip when ToolTip is enabled.
| UIComponent | |
![]() | x : Number | UIComponent | |
![]() | y : Number | UIComponent | |
| Method | Defined by | ||
|---|---|---|---|
|
Menu(orientation:int = 0)
| Menu | ||
![]() |
addItem(item:Object):void
Adds an item to the end of the item list.
| List | |
![]() |
addItemAt(item:Object, index:int):void
Adds an item at the specified index.
| List | |
![]() |
addItemsAt(items:Array, index:int):void
Inserts multiple items at the specified index.
| List | |
![]() |
clone():*
Returns a clone of the component.
The skin of the component is cloned but other things like the text of a label or the items of a list aren't. | UIComponent | |
![]() |
getAll():Array
Retrieves all items.
| List | |
![]() |
getItemAt(index:int):Object
Retrieves the item at the specified index.
| List | |
![]() |
getItemIndex(item:Object):int
Retrieves the index of the specified item.
| List | |
![]() |
move(x:int, y:int, animationMode:int = 0, animationFrames:int = 12, easeInOut:Boolean = false):void
Moves the component to the specified coordinates.
| UIComponent | |
|
[static] Registers a menu alias.
| Menu | ||
|
registerStyle(style:*, alias:String):void
[static] Registers a style alias.
| Menu | ||
![]() |
removeAll():void
Removes all items from the list.
| List | |
![]() |
removeItem(item:Object):Object
Removes the specified item from the list.
| List | |
![]() |
removeItemAt(index:int):Object
Removes the item at the specified index position from the list.
| List | |
![]() |
replaceItemAt(item:Object, index:int):Object
Replaces the item at the specified index with another item.
| List | |
![]() |
setDataXML(data:*, sort:int = 0, labelFunction:Function = null, iconFunction:Function = null):void
Set the list data.
data can be of the type XML or URLRequest. sort can be 0 (no sort), 1 (ascending), 2 (descending). iconFunction if provided should be a function that accepts one parameter for the item object and returns the icon bitmap data. | List | |
![]() |
setItemArray(itemArray:Array):void
Specifies the array to use for items.
| List | |
![]() |
setProperties(o:Object):void
Sets a number of properties at once.
| UIComponent | |
|
setStyle(styleAlias:String):void
Sets the menu style.
| Menu | ||
![]() |
sortItemsOn(field:String, options:Object = null):*
Sorts the items of the list according to one or more item fields.
| List | |
| Event | Summary | Defined by | ||
|---|---|---|---|---|
![]() | The animationComplete event is broadcasted when an animated move is completed. | UIComponent | ||
![]() | The change event is broadcasted when a different item is selected. When the selection is changed by scripting, the event is not broadcasted. It's also possible to use the onChange handler. | List | ||
| The menu event is broadcasted when a menu item is clicked. It's also possible to use the onMenu handler. | Menu | |||
![]() | The noChange event is broadcasted when an already selected item is clicked again. | List | ||
![]() | The setDataComplete event is broadcasted when the setDataXML function has completed. | List | ||
![]() | The setDataError event is broadcasted when the setDataXML function has failed. | List | ||
| Constant | Defined by | ||
|---|---|---|---|
| HORIZONTAL : int = 1 [static]
| Menu | ||
| HORIZONTAL_CONDENSED : int = 2 [static]
| Menu | ||
| VERTICAL : int = 0 [static]
| Menu | ||
| lastClicked | property |
lastClicked:Object [read-only]Gets the last item that was clicked.
Implementation public function get lastClicked():Object
| onMenu | property |
public var onMenu:FunctiononMenu handler.
| orientation | property |
orientation:int [read-only]Gets the orientation of the menu.
Implementation public function get orientation():int
| Menu | () | constructor |
public function Menu(orientation:int = 0)Parameters
orientation:int (default = 0) |
| register | () | method |
public static function register(menu:Menu, alias:String):voidRegisters a menu alias.
Parametersmenu:Menu |
|
alias:String |
| registerStyle | () | method |
public static function registerStyle(style:*, alias:String):voidRegisters a style alias.
Parametersstyle:* |
|
alias:String |
| setStyle | () | method |
public function setStyle(styleAlias:String):voidSets the menu style.
ParametersstyleAlias:String |
| menu | event |
flash.events.Event
The menu event is broadcasted when a menu item is clicked.
It's also possible to use the onMenu handler.
| HORIZONTAL | constant |
public static const HORIZONTAL:int = 1
| HORIZONTAL_CONDENSED | constant |
public static const HORIZONTAL_CONDENSED:int = 2
| VERTICAL | constant |
public static const VERTICAL:int = 0