The target can also be set once the Effect has been instantiated by using the target property of the Effect class. The target is the UIComponent that the Effect will affect when the play method of the Effect is called. When an Effect is defined in MXML, the target UIComponent must be assigned within a binding tag: 目标的设置也可以在Effect 实例化完成后通过设置Effect 类的target 属性来完成。所谓目标就是一个当调用Effect 的play 方法的时候会对其产生作用的UIComponent。当一个Effect定义在MXML 后,目标UIComponent 必须以绑定标签的形式进行分配:
<mx:VBoxxmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="600"> <mx:Script> <![CDATA[ import mx.effects.Blur; privatevar blur:Blur; privatefunction applyBlur():void { blur = new Blur(glowingTI); blur.blurXFrom = 0; blur.blurXTo = 20;//the amount of blur in pixels blur.blurYFrom = 0; blur.blurYTo = 20;//the amount of blur in pixels blur.duration = 1000; blur.play(); }
]]> </mx:Script> <!--the properties of the Glow effect set here are the color of the Glow and the length of time that the Glow will be displayed --> <mx:Glowid="glowEffect" duration="1000" color="#ff0f0f" target="{glowingTI}"/> <mx:TextInputid="glowingTI"/> <mx:Buttonclick="applyBlur()" toggle="true" id="glowToggle" label="Play the BlurEffect"/> <mx:Buttonclick="glowEffect.play()" label="Play the Glow Effect"/> </mx:VBox>