Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
554 CHAPTER 17 Applying behaviors in MXML In MXML, you use a trigger name as a property of a component's MXML tag to configure an effect for the component. For example, to configure a Button control to use the WipeLeft effect when the user clicks the control, you use the mouseDownEffect trigger property in an <mx:Button> tag, as the following example shows: <?xml version="1.0"?> <!-- behaviors\ButtonWL.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <!-- Define effect. --> <mx:WipeLeft id="myWL" duration="1000"/> <!-- Assign effect to targets. --> <mx:Button id="myButton" label="Click Me" mouseDownEffect="{myWL}"/> <mx:Button id="myOtherButton" label="Click Me" mouseDownEffect="{myWL}"/> </mx:Application> In the next example, you create two Resize effects for a Button control. One Resize effect expands the size of the button by 10 pixels when the user clicks down on the button, and the second resizes it back to its original size when the user releases the mouse button. The duration of each effect is 200 ms. <?xml version="1.0"?> <!-- behaviors\ButtonResize.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > <mx:Resize id="myResizeUp" widthBy="50" heightBy="50" duration="200" /> <mx:Resize id="myResizeDown" widthBy="-50" heightBy="-50" duration="200" /> <mx:Button id="myButton" label="Click Me" mouseDownEffect="{myResizeUp}" mouseUpEffect="{myResizeDown}" /> </mx:Application> Applying behaviors in MXML using data binding You can use data binding in MXML to set properties of an effect. For example, the following example lets the user set the zoomHeightTo and zoomWidthTo properties of the Zoom effect using a TextInput control. The zoomHeightTo and zoomWidthTo properties specify a number that represents the scale at which to complete the zoom, as a value between 0.0 and 1.0. The default value is 1.0, which is the object's normal size. <?xml version="1.0"?>