Configuring components: syntax summary

The following table summarizes the MXML and ActionScript component APIs that you use to configure components:

 

MXML example

ActionScript example

Read-write

property

<mx:Tile id="tile1"
label="My Tile"
visible="true"/>
tile1.label="My Tile"; tile1.visible=true;

Read-only property

You cannot use a read-only property as an attribute in MXML.

To get the value of a read-only property:

var theClass:String=mp1.className;

Method

Methods are not available in MXML.

myList.sortItemsBy("data", "DESC");

Event

<mx:Accordion id="myAcc"
change="changeHandler
(event);"/>

(You must also define a changeHandler() function as shown in the ActionScript example.

private function
changeHandler(event:MouseEvent):void {
... } myButton.addEventListener("click", changeHandler);

Style

<mx:Tile id="tile1"
paddingTop="12"
paddingBottom="12"/>

To set the style:

tile1.setStyle("paddingTop", 12); tile1.setStyle("paddingBottom", 12);

To get the style:

var currentPaddingTop:Number = tile1.getStyle("paddingTop");.

Behavior

<mx:Tile id="tile1"
showEffect="{AWipeEffect}"/>

To set the behavior:

myButton.setStyle('showEffect', 
AWipeEffect);

To get the behavior:

var currentShowEffect:String = tile1.getStyle("showEffect");

Flex 2.01

Take a survey