User Guide
Example: Creating a composite component 175
■ You can use both the textPlacement property or the text property as the source for a
data binding expression.
■ You can optionally use skins for the up, down, and over states of the Button control.
The following is an example MXML file that uses the ModalText control and sets the
textPlacement property to left:
<?xml version="1.0"?>
<!-- asAdvanced/MainModalText.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*" >
<MyComp:ModalText textPlacement="left"/>
</mx:Application>
You can handle the placementChanged event to determine when the
ModalText.textPlacement property is modified, as the following example shows:
<?xml version="1.0"?>
<!-- asAdvanced/MainModalTextEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*" >
<mx:Script>
<![CDATA[
import flash.events.Event;
private function placementChangedListener(event:Event):void {
myEvent.text="placementChanged event occurred - textPlacement = "
+ myMT.textPlacement as String;
}
]]>
</mx:Script>
<MyComp:ModalText id="myMT" textPlacement="left"
placementChanged="placementChangedListener(event);"/>
<mx:TextArea id="myEvent" width="50%"/>
<mx:Label text="Change Placement" />
<mx:Button label="Set Text Placement Right"
click="myMT.textPlacement='right';" />
<mx:Button label="Set Text Placement Left"
click="myMT.textPlacement='left';" />
</mx:Application>