---
title: "FlextiggerEventEffect(二)"
author: "demojava"
date: "2011-09-25T21:13:32Z"
tags: []
categories: ["Web前端"]
slug: "flextiggereventeffect"
draft: false
lastmod: "2011-09-25T21:13:32Z"
id: 1180188
url: "https://demojava.iteye.com/blog/1180188"
---

**flex tiggerEventEffect**

 

**触发器名称** **触发事件** addedEffect 组件作为一个子类被添加到一个容器中 creationCompleateEffect 组件被建立 focusInEffect 组件获得键盘的焦距 focusOutEffect  组件失去键盘的焦距 hideEffect 通过设定主键的visible 属性从true到false而成为不可见的 mouseDownEffect  当鼠标在某个组件上时，用户按下鼠标键盘 mouseUpEffect  用户释放鼠标按键 moveEffect 组件被移动 removedEffect 组件在容器中被删除 resizeEffectt 组件呗改变大小 rollOutEffect 用户将鼠标从组件上移开 rollOverEffect  用户将鼠标移动到组件 showEffect 通过设定主键的visible 属性从false 到 true 而成为不可见的

 

1.在mxml中使用 使用组件对应的 tiggerEventEffect  
l例如：  
&lt;mx:WipeLeft id="myWL"  
&lt;mx:Button id="btn1" mouseDownEffect="{myWL}" /&gt;

2.在mxml中使用样式表来实现行为的控制  
&lt;mx:Style&gt;  
 Button  
 {  
  mouseDownEffect:slowWipe;  
 }   
&lt;/mx:Style&gt;  
&lt;mx:WipeLeft id="slowWipe" duration="500" /&gt;  
&lt;mx:Button id="btn1" /&gt;  
当然也把某个组件对应的效果去除  
&lt;mx:Button id="btn1" mouseDownEffect="none"/&gt;

3.使用setStyle()和getStyle()函数在mxml中定义效果  
语法：setStyle("触发器",效果);  
   getStyle("触发器"):返回的类型  
&lt;mx:WipeLeft id="slowWipe" duration="500" /&gt;  
&lt;mx:Button id="btn1"  mouseDownEffect="slowWipe"/&gt;  
//使用  
var myStyle:Number=btn1.getStyle("mouseDownEffect").duration;

4.顺序显示控件的效果  
slowWipe.play(\[btn1,btn2,btn3],true);

5.终止/暂停效果  
&lt;mx:WipeLeft id="slowWipe" duration="500" /&gt;  
&lt;mx:Button id="btn1" click="{slowWipe.play()}"/&gt;  
&lt;mx:Button id="btn2" click="{slowWipe.end()}"/&gt;

6.Effect.target和Effect.targets绑定组件  
&lt;mx:WipeLeft id="slowWipe" duration="500" targets="{\[btn1,btn2]}" /&gt;  
&lt;mx:Button id="btn1" click="{slowWipe.play()}"/&gt;  
&lt;mx:Button id="btn2" click="{slowWipe.end()}"/&gt;

7.组合效果  
平行(parallel):所有行为效果都在同一时间进行  
排序(sequence):一个行为效果结束，下一个行为效果开始  
   
&lt;mx:Parallel id="zoomshow"&gt;  
 &lt;mx:Zoom id="myZoomshow" zoomHeightFrom="0.0" zoomWidthFrom="0.0"  
  zoomHeightTo="1.0" zoomWidthTo="1.0"  /&gt;  
  &lt;mx:Rotate id="rotateshow" /&gt;  
&lt;/mx:Parallel&gt;  
&lt;mx:Sequence id="zoomhide"&gt;  
  &lt;mx:Zoom id="myZoomhide" zoomHeightFrom="1.0" zoomWidthFrom="1.0"  
  zoomHeightTo="0.0" zoomWidthTo="0.0"  /&gt;  
  &lt;mx:Rotate id="rotatehide" /&gt;  
&lt;/mx:Sequence&gt;  
    &lt;mx:Panel x="257" y="168" width="389" height="273" horizontalAlign="center" verticalAlign="middle"&gt;  
     &lt;mx:TextInput id="txt" hideEffect="{zoomhide}" showEffect="{zoomshow}" /&gt;  
           &lt;mx:Button label="显示" click="{txt.visible=true;}"/&gt;  
           &lt;mx:Button label="隐藏" click="{txt.visible=false;}"/&gt;  
    &lt;/mx:Panel&gt;

8.使用动画属性(AnimateProperty)效果  
&lt;mx:Sequence id="zoomshow"&gt;  
     &lt;mx:AnimateProperty property="scaleY" fromValue="1" toValue="1.5" duration="1000" /&gt;  
 &lt;mx:AnimateProperty property="scaleY" fromValue="1.5" toValue="1" duration="1000" /&gt;  
&lt;/mx:Sequence&gt;  
&lt;mx:Panel  x="260" y="180" width="450" height="304" paddingTop="10" paddingLeft="10" paddingBottom="10"&gt;  
  &lt;mx:Image source="[http://www.baidu.com/img/baidu\_sylogo1.gif](http://www.baidu.com/img/baidu_sylogo1.gif)" mouseDownEffect="zoomhide" /&gt;  
&lt;/mx:Panel&gt;

9.重复(Repeating)效果  
&lt;mx:Rotate id="myRotate" repeatCount="0"/&gt;  
&lt;mx:Panel  x="260" y="180" width="450" height="304" paddingTop="10" paddingLeft="10" paddingBottom="10"&gt;  
&lt;mx:Image id="image" source="[http://www.baidu.com/img/baidu\_sylogo1.gif](http://www.baidu.com/img/baidu_sylogo1.gif)" mouseDownEffect="myRotate" /&gt;  
&lt;mx:Button id="btn" label="停止转动" click="myRotate.end();" /&gt;  
&lt;/mx:Panel&gt;

10.延迟(Delaying)行为效果  
&lt;mx:Rotate id="myRotate" repeatCount="2" startDelay="1000"/&gt;  
&lt;mx:Panel  x="260" y="180" width="450" height="304" paddingTop="10" paddingLeft="10" paddingBottom="10"&gt;  
&lt;mx:Image id="image" source="[http://www.baidu.com/img/baidu\_sylogo1.gif](http://www.baidu.com/img/baidu_sylogo1.gif)" mouseDownEffect="myRotate" /&gt;  
&lt;mx:Button id="btn" label="停止转动" click="myRotate.end();" /&gt;  
&lt;/mx:Panel&gt;

11遮罩(Mask)行为效果  
&lt;mx:Script&gt;  
 &lt;![CDATA[  
  public function createLargeMask(targ:Object,bounds:Rectangle):Shape{  
   var largeMask:Shape=new Shape();  
    largeMask.graphics.beginFill(0x00FFFF,1.5);  
    largeMask.graphics.drawCircle(50,50,bounds.width/2);  
    largeMask.graphics.endFill();  
    return largeMask;  
  }  
 ]]&gt;  
&lt;/mx:Script&gt;  
&lt;mx:WipeLeft id="customWL" createMaskFunction="createLargeMask"  
showTarget="false" duration="1000"/&gt;  
&lt;mx:Panel  x="260" y="180" width="450" height="304" paddingTop="10" paddingLeft="10" paddingBottom="10"&gt;

&lt;mx:Image id="image" source="[http://www.baidu.com/img/baidu\_sylogo1.gif](http://www.baidu.com/img/baidu_sylogo1.gif)" mouseDownEffect="myRotate" /&gt;

&lt;mx:Button id="btn" label="停止转动" mouseDownEffect="{customWL}" height="100" width="100" fillAlphas="\[1.0,1.0]"  
 fillColors="\[#DBA65B,#5EDB5B]"  
/&gt;  
&lt;/mx:Panel&gt;