Graphics Reference
In-Depth Information
Table 12.3 The Variables of the SimpleMenu Class
Variable
Purpose
HORIZONTAL (public, static String)
Option for laying out the menu in the horizontal direction
VERTICAL (public, static String)
Option for laying out the menu in the vertical direction
_layout (String)
Holds the chosen layout
_spacing (Number)
The number of pixels to place between menu items
_menuItem (Sprite)
Used for the creation and manipulation of each menu item
_menuItemLabel (TextField)
Used for the creation and manipulation of each menu item label
_upBackground (uint)
The background color of the menu items in the upstate; default is black
_overBackground (uint)
The background color of the menu items in the overstate; default is black
_downBackground (uint)
The background color of the menu items in the downstate; default is black
_backgroundUpAlpha (Number)
The background alpha of the menu items in the upstate; default is 1 (100%)
_backgroundOverAlpha (Number)
The background alpha of the menu items in the overstate; default is 0.5 (50%)
_backgroundDownAlpha (Number)
The background alpha of the menu items in the downstate; default is 0
_labelFormatUp (TextFormat)
The TextFormat used for the menu item labels in the upstate
_labelFormatOver (TextFormat)
The TextFormat used for the menu item labels in the overstate
_labelFormatDown (TextFormat)
The TextFormat used for the menu item labels in the downstate
_stateBackgroundColor (uint)
Holds the background color of the current state of a menu item that is
being interacted with
_stateBackgroundAlpha (Number)
Holds the background alpha of the current state of a menu item that is
being interacted with
_stateTextFormat (TextFormat)
Holds the TextFormat of the current state of a menu item's label that is
being interacted with
menu items. spacing defaults to 0 if nothing is passed in. The other
optional parameter, layout ,tellstheSimpleMenuthedirectionin
which to organize the menu items. The options are horizontal and
vertical with the default being set to horizontal. Once inside the
SimpleMenu class constructor, we
ll make the values of the spacing
and layout parameters available to the rest of the class by assigning
them to the private variables through the (almost) same names of
_layout and _spacing . The next line calls the setDefaultFormats
method, which we
'
'
llgettoinjustabit.Afterthatcall,Iusethe forEach
method from the Array class to call the createMenuItem method with
each item of the menuArray . More on that a little further in as well.
public function SimpleMenu(menuArray:Array, spacing:Number
= 0, layout:String = " horizontal " ){
_layout = layout;
_spacing = spacing;
setDefaultFormats();
menuArray.forEach(createMenuItem);
}
Search WWH ::




Custom Search