zoomMenu Actionscript Reference
The Zoom Menu component consists of two api's:
ZoomMenu Class
The ZoomMenu class represents an instance of the Zoom Menu component. ZoomMenu is a subclass of MovieClip and thus it also contains all MovieClip methods, properties and events.
Methods
load(url:String):Void
Loads the specified xml document into the Zoom Menu and replicates it structure.
Parameters:
It can be relative or absolute, it can be a file on the internet or a file on the same server as the Flash Movie:
Returns:
Nothing
Usage:
menu_mc.load("http://www.mysite.com/menu.xml")
parseXML(xmlStr:String):Void
Replicates the structure of the specified string of xml.
Parameters:
Usage:
menu_mc.parseXML("<menu><products label='Products' backgroundColor="0xFFCC00" /></menu>");
getBytesLoaded():Number
Returns the number of bytes loaded (streamed) for the XML document. You can compare the value of getBytesLoaded() with the value of getBytesTotal() to determine what percentage of an XML document has loaded.
Parameters:
None
Usage:
menu_mc.getBytesTotal()
getBytesTotal():Number
Returns the size, in bytes, of the XML document.
Parameters:
None
Usage:
menu_mc.getBytesLoaded()
addEventListener(eventName:String,listener:Object):Void
Registers a listener object with the menu instance that is broadcasting an event. When the event occurs, the listener object or function is notified.
Parameters:
Returns:
Nothing
Usage:
this.xmlLoaded=function(success)
{
if(success)
{
//do something
}
}
menu_mc.addEventListener("xmlLoaded",this)
removeEventListener(eventName:String,listener:Object):Void
Un-registers a listener object with the menu instance. When the event occurs, the listener object or function will no longer be notified.
Parameters:
Returns:
Nothing
Usage:
menu_mc.removeEventListener("xmlLoaded",this)
Properties
labelColor
Retrieves the default color of all labels in the menu
Usage:
lblC=menu_mc.labelColor
labelSize
Retrieves the text size of all the labels in the menu.
Usage:
lblSize=menu_mc.labelSize
embedFonts
Determines whether the label for each menu item will be rendered with embedded fonts (true) or not (false). When zooming embedded fonts are smoother, whereas if you dont embed the fonts the text resizing is really jurky. For more information See Using Embedded Fonts.
Usage:
fontsEmbedded=menu_mc.embedFonts
root
Returns the top of the tree; the root node.
Usage:
topNode=menu_mc.root
selected
Sets or retrieves the selected Menu Item, if you set the selected menu item and it is already selected, the menu will zoom out to its parent menu item. If its not selected the menu will zoom into the specified menu item.
Usage:
productsNode=menu_mc.root.getItemAt(2,2) menu_mc.selected=productsNode or selectedNote=menu_mc.selected
gridSize
Retrieves the size of the layout grid and thus the size of each menu item. A grid size of 4 means that the grid inside of each menu item will contain 4 rows and 4 columns. For more information See Grid Layout.
cellWidth=((menu_mc.size/menu_mc.gridSize)/100)*(100/menu_mc.gridSize)
frames
Changes or retrieves the speed at which the Zoom animation occurs when a menu item is clicked on. Where zero (0) means no animation. The higher the number the slower the animation.
Usage:
menu_mc.frames=10 or speed=menu_mc.frames
size
Retrieves the width & height of the menu's viewable area. For more information see Grid Layout.
Usage:
menuWidth=menu_mc.size
cellSize
Retrieves the size of each menu item in the layout grid before it is scaled. For more information see Grid Layout.
Usage:
cellSize=menu_mc.cellSize
Events
xmlLoaded
Notifies listeners when an xml document has loaded after a load() method is called.
Usage:
function xmLoaded(success)
{
if(success)
{
}
}
menu_mc.addEventListener("xmlLoaded",this)
menu_mc.load("http://www.mysite.com/menu.xml")
selectedChanged
Notifies listeners when the selected item in the menu changes
Usage:
function selectedChanged()
{
var newSelection=menu_mc.selected
}
menu_mc.addEventListener("selectedChanged",this)
zoomFinished
Notifies listeners when the new selection has finished the zoom animation
Usage:
function zoomFinished()
{
var newSelection=menu_mc.selected
}
menu_mc.addEventListener("zoomFinished",this)
ZoomMenuItem Class
The ZoomMenuItem Class represents an invidual menu item. ZoomMenuItem is a subclass of MovieClip and thus it also contains all MovieClip methods, properties and events.
Methods
center():Void
Centers the child menu items inside of the square of a menu item.
Parameters:
None
Returns:
Nothing
Usage:
menu_mc.getItemAt(0,0).center()
addItem(label;String,backgroundColor:Number,labelColor:Number,gridSize:Number):ZoomMenuItem
Creates a new menu item and places it in the next available cell.
Parameters:
Returns:
A reference to the newly created menu item if it was successfully created, otherwise undefined.
Usage:
menu_mc.root.addItem("Services",0xFF0000,0x000000)
For more information on Cell's, Row's and Column's See Grid Layout
addItemAt(row:Number,column:Number,label;String,backgroundColor:Number,labelColor:Number,gridSize:Number):ZoomMenuItem
Creates a new menu item and places it inside the specified cell.
Parameters:
Returns:
A reference to the newly created menu item if it was successfully created, otherwise undefined.
Usage:
menu_mc.root.addItemAt(0,0,"Products",0xFF0000,0x000000)
For more information on Cell's, Row's and Column's See Grid Layout
removeItemAt(row:Number,column:Number):Void
Removes the child menu item from the specified cell.
Parameters:
Returns:
Nothing
Usage:
menu_mc.root.removeItemAt(0,0)
For more information on Cell's, Row's and Column's See Grid Layout
getItemAt(row:Number,column:Number):ZoomMenuItem
Returns a reference to the child menu item which is located in the specified cell.
Parameters:
Returns:
A reference to the specified child menu item. If the specified cell is empty, undefined is returned.
Usage:
productsItem=menu_mc.root.getItemAt(0,0)
For more information on Cell's, Row's and Column's See Grid Layout
countItems():Number
Returns the number of child menu items.
Parameters:
None
Usage:
numChildren=menu_mc.root.countItems()
Properties
label
Retrieves or changes the label of a menu item.
Usage:
menu_mc.root.getItemAt(0,0).label="Services" or pLabel=menu_mc.root.getItemAt(2,1).label
labelColor
Retrieves or changes the colour of the label for a menu item.
Usage:
menu_mc.root.getItemAt(1,0).labelColor=0x000000 or lColor=menu_mc.root.getItemAt(2,1).labelColor
backgroundColor
Retrieves or sets the background color of a menu item
Usage:
menu_mc.root.getItemAt(0,0).backgroundColor=0xFFCC00 or bgColor=menu_mc.root.getItemAt(1,2).backgroundColor
level
Retrieves the depth of the current menu item in the tree.
Usage:
currentLevel=menu_mc.selected.level
labelPlacement
Retrieves or changes the position of the label within a menu item. Possible values are "topLeft", "topRight", "center", "bottomLeft", "bottomRight"
Usage:
menu_mc.selected.labelPlacement="topRight" or lblPosition=menu_mc.selected.labelPlacement
isSelected
Returns a boolean value (true/false) that determines whether the menu item is selected or not.
Usage:
isSelected=menu_mc.root.getItemAt(0,1).isSelected