FlextiggerEventEffect(二)

本文介绍如何在Flex中使用各种效果和触发器,包括直接在MXML中定义、使用样式表、设置和获取效果风格等。同时涵盖了平行效果、排序效果、重复效果及延迟效果等多种高级用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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例如:
<mx:WipeLeft id="myWL"
<mx:Button id="btn1" mouseDownEffect="{myWL}" />

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

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

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

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

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

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

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

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

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

11遮罩(Mask)行为效果
<mx:Script>
 <![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;
  }
 ]]>
</mx:Script>
<mx:WipeLeft id="customWL" createMaskFunction="createLargeMask"
showTarget="false" duration="1000"/>
<mx:Panel  x="260" y="180" width="450" height="304" paddingTop="10" paddingLeft="10" paddingBottom="10">

<mx:Image id="image" source="http://www.baidu.com/img/baidu_sylogo1.gif" mouseDownEffect="myRotate" />

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值