Packagekm.components
Classpublic class Menu
InheritanceMenu Inheritance List Inheritance ScrollPane Inheritance UIComponent Inheritance flash.display.Sprite

The Menu component class.
When a menu item has sub items, a few extra attributes (orientation, subwidth, substyle) can be used to set up the sub menu. To use a substyle, first register one using the static registerStyle function. You can pass a menu or list instance for style.
When a menu does not have sub items, the submenu attribute can be used to attach another menu as a submenu by specifying its registered alias.


Example
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;




Public Properties
 PropertyDefined by
 Inheritedbackground : Image
>> Reference to the background image.
ScrollPane
 Inheritedduotone : Array
The duotone property can be used to convert the colors of the component into duotone.
UIComponent
 Inheritedenabled : Boolean
Specifies if the component is enabled.
If a component is disabled, it will be turned into grayscale and become partly transparent.
UIComponent
 InheritedhtmlLabels : Boolean
Gets or sets a Boolean value indicating if item labels should be displayed as html text or plain text.
List
 InheritediconField : String
Gets or sets the name of the field that contains the item label icon.
List
 InheritedlabelField : 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
 Inheritedlength : uint
Gets the number of items in the list.
List
 InheritedlistItem : ListItem
>> Reference to the default list item.
List
 Inheritedmargin : int
The margin between the bounding box of the background and the sub components inside.
ScrollPane
 InheritedonChange : Function
onChange handler.
List
  onMenu : Function
onMenu handler.
Menu
  orientation : int
[read-only] Gets the orientation of the menu.
Menu
 InheritedtoolTip : String
Text to use as toolTip when ToolTip is enabled.
UIComponent
 Inheritedx : Number
UIComponent
 Inheritedy : Number
UIComponent
Public Methods
 MethodDefined by
  
Menu(orientation:int = 0)
Menu
 Inherited
addItem(item:Object):void
Adds an item to the end of the item list.
List
 Inherited
addItemAt(item:Object, index:int):void
Adds an item at the specified index.
List
 Inherited
addItemsAt(items:Array, index:int):void
Inserts multiple items at the specified index.
List
 Inherited
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
 Inherited
getAll():Array
Retrieves all items.
List
 Inherited
getItemAt(index:int):Object
Retrieves the item at the specified index.
List
 Inherited
getItemIndex(item:Object):int
Retrieves the index of the specified item.
List
 Inherited
move(x:int, y:int, animationMode:int = 0, animationFrames:int = 12, easeInOut:Boolean = false):void
Moves the component to the specified coordinates.
UIComponent
  
register(menu:Menu, alias:String):void
[static] Registers a menu alias.
Menu
  
registerStyle(style:*, alias:String):void
[static] Registers a style alias.
Menu
 Inherited
removeAll():void
Removes all items from the list.
List
 Inherited
removeItem(item:Object):Object
Removes the specified item from the list.
List
 Inherited
removeItemAt(index:int):Object
Removes the item at the specified index position from the list.
List
 Inherited
replaceItemAt(item:Object, index:int):Object
Replaces the item at the specified index with another item.
List
 Inherited
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
 Inherited
setItemArray(itemArray:Array):void
Specifies the array to use for items.
List
 Inherited
setProperties(o:Object):void
Sets a number of properties at once.
UIComponent
  
setStyle(styleAlias:String):void
Sets the menu style.
Menu
 Inherited
sortItemsOn(field:String, options:Object = null):*
Sorts the items of the list according to one or more item fields.
List
Events
 EventSummaryDefined by
 Inherited The animationComplete event is broadcasted when an animated move is completed.UIComponent
 Inherited 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
 Inherited The noChange event is broadcasted when an already selected item is clicked again.List
 Inherited The setDataComplete event is broadcasted when the setDataXML function has completed.List
 Inherited The setDataError event is broadcasted when the setDataXML function has failed.List
Public Constants
 ConstantDefined by
  HORIZONTAL : int = 1
[static]
Menu
  HORIZONTAL_CONDENSED : int = 2
[static]
Menu
  VERTICAL : int = 0
[static]
Menu
Property detail
lastClickedproperty
lastClicked:Object  [read-only]

Gets the last item that was clicked.

Implementation
    public function get lastClicked():Object
onMenuproperty 
public var onMenu:Function

onMenu handler.

orientationproperty 
orientation:int  [read-only]

Gets the orientation of the menu.

Implementation
    public function get orientation():int
Constructor detail
Menu()constructor
public function Menu(orientation:int = 0)

Parameters
orientation:int (default = 0)
Method detail
register()method
public static function register(menu:Menu, alias:String):void

Registers a menu alias.

Parameters
menu:Menu
 
alias:String
registerStyle()method 
public static function registerStyle(style:*, alias:String):void

Registers a style alias.

Parameters
style:*
 
alias:String
setStyle()method 
public function setStyle(styleAlias:String):void

Sets the menu style.

Parameters
styleAlias:String
Event detail
menuevent 
Event object type: flash.events.Event

The menu event is broadcasted when a menu item is clicked.
It's also possible to use the onMenu handler.

Constant detail
HORIZONTALconstant
public static const HORIZONTAL:int = 1
HORIZONTAL_CONDENSEDconstant 
public static const HORIZONTAL_CONDENSED:int = 2
VERTICALconstant 
public static const VERTICAL:int = 0