This article explains the use of the Flash Lite Menu component and API.
Contents |
The Flash Lite Menu component is a flexible and scalable user interface component that allows Flash Lite developers to create mobile user interfaces easily, using Flash Lite.
| |
|
| Figure 1. Menu component. | Figure 2. Menu component with Scrollbar. | Figure 3. Menu component with ScrollBar over the skin. |
Menu component can be downloaded here.
Installation of the Menu component is easy. Execute the components MXP file and follow the simple instructions in Adobe Extension Manager to complete the installation process. Restart Adobe Flash CS4 after installation.
Note: Component FLA and AS files should appear in the directories [INSTALL PATH]\Flash CS4\en\Configuration\Components\Forum Nokia, [INSTALL PATH]\Flash CS4\en\Configuration\Classes\com\forumnokia and [INSTALL PATH]\Flash CS4\en\Configuration\Classes\gs. In some setup environments, the files may appear under the wrong language directories (for example, fi instead of en). In such cases, the files should be manually moved to the correct directories as specified above.
fscommand2("DisableKeypadCompatibilityMode");
fscommand2("FullScreen", true);
fscommand2("SetQuality", "high");
Stage.scaleMode = "noScale";
Stage.align = "TL";
_focusrect = false;
//Params: (Label, Data)
myMenu.addRootItem("Item 1", 1);
myMenu.addRootItem("Item 2", "second");
myMenu.addRootItem("Item 3", 3);
myMenu.addRootItem("Item 4", {i:4});
myMenu.addRootItem("Item 5", [5]);
//Params: (Parent Index, Label, Data)
myMenu.addChildItemAt(0, "SubItem 1.1", 1.1);
myMenu.addChildItemAt(0, "SubItem 1.2", 1.2);
myMenu.addChildItemAt(0, "SubItem 1.3", 1.3);
myMenu.addChildItemAt(2, "SubItem 3.1", 3.1);
myMenu.addChildItemAt(2, "SubItem 3.2", 3.2;
myMenu.addChildItemAt(4, "SubItem 5.1", 5.1);
var myChangeEvent:String = myMenu.onChangeEvent();
myMenu.addEventListener(myEvent, myListener);
function myListener(eventObject:Object):Void {
if (eventObject.type == myChangeEvent) {
trace("Item: "+eventObject.item);
trace("Label: "+eventObject.label);
trace("Data: "+eventObject.data);
}
}
The asset of a menu component is composed of 2 different parts. Each asset has separate MovieClips for Up and Down states of the menu, which are organised in the following structure:
_assets
NOTE: Custom assets must follow the same folder structure, and linkage identifiers must be named accordingly.
The skin of a menu component is composed of 12 different parts for each state, up and down, as can be seen below. This structure enables the menu interface to be scalable and easily skinnable.
Skins have separate MovieClips for Up and Down states of the Menu. The structure of these parts is defined below:
_skins
Note: Each new custom skin must follow the same folder structure, with linkage identifiers named accordingly.
Inspectable parameters help customise the Menu component from the Component Inspector panel (Shift + F7). All inspectable parameters can also be controlled via ActionScript with the component APIs.
| Parameter | Description | Value |
|---|---|---|
| Skin | Defines the menu skin linkage identifier path. For instance, for the mySkin value, the menu would search for the skin components under the Menu.mySkin.* linkage path. | Skin identifier string |
| Assets | Defines the menu asset linkage identifier path. For instance, for the myAssets value, the component would search for the assets under the Menu.myAssets.* linkage path. | Skin identifier string |
| Label Alignment | Defines the text alignment of the label asset. | center/left/right |
| ScrollBar Position | Defines the scroll bar position when it is visible. | KeepComponentWidth, ExpandComponentWidth, OverComponentSkin |
| Time Animation | Defines the time of open submenu animation. | Number |
public function setAsset( path:String ): Void;
Sets a new path for the assets. Reconstructs the component.
public function setSkin( path:String ): Void;
Sets a new path for the skin. Reconstructs the component.
public function enableComponent() :Void;
Makes the component react to user input.
public function disableComponent() :Void;
Makes the component stop reacting to user input.
public function addRootItem(label:String, data):Void;
Insert one Root Item on Menu Component.
public function addChildItemAt(rootIndex:Number, label:String, data):Void;
Insert the subItem that has the index given by the parameter.
NOTE: Each Item and Sub Item has an attribute data that can store any information to be used by the user
public function setSelectedItem(item:MovieClip):Void;
Set selected Item.
public function getSelectedItem():MovieClip;
Get selected Item.
public function unSelectItem():Void;
Unselect the selected Item
public function alignLabelField(newPosition:String):Void;
Change the Itens and subItens label alignment.
setEasingFunction(func:Function):Void
Set a custom easing function. You can use any easing equation written in ActionScript 2. Has many easing equations in TweenLite Package
public function onChangeEvent():String;
Calls the menu component’s change event.
public function onPressItemEvent():String;
Calls the menu component's press an item event.
public function onReleaseItemEvent():String;
Calls the menu component itens release an item event.
public function onStartItemAnimationEvent():String
Calls the menu component’s start animation event.
public function onStopItemAnimationEvent():String;
Calls the menu component’s stop animation event.
public function onStartDragScrollBarEvent():String;
Calls the menu component’s start drag scroll bar event.
public function onStopDragScrollBarEvent():String;
Calls the menu component’s stop drag scroll bar event.
No related wiki articles found