zoukankan      html  css  js  c++  java
  • 特效

    常见效果类:

          AnimateProperty:动画属性
          Blur :模糊
          Desolve :溶解
          Fade :凋零
          Glow :发光
          Iris :瞳孔放大缩小
          Move :移动
          Pause :定格
          Resize :改变大小
          Rotate :旋转
          SoundEffect :音效
          (WipeLeft, WipeRight, WipeUp, WipeDown) :擦拭
          Zoom :放大缩小

          Sequence:顺序播放组合

          Parallel:同时播放组合

    常见触发动画效果方式:

          AddedEffect :加入容器
          creationCompleteEffect :创建完成
          focusInEffect :获得键盘输入
          focusOutEffect :失去键盘输入
          hideEffect :visable属性设置为false
          mouseDownEffect :鼠标按下
          mouseUpEffect :鼠标按起
          moveEffect :被拖动
          resizeEffect :重新设定大小
          removedEffect :被移除
          rollOutEffect :鼠标移到控件外
          rollOverEffect :鼠标移到控件上
          showEffect :visable属性设置为true

    部分示例:

         

    1:glow(发光)

    代码:

    <mx:Glow id="glow" duration="1000"

            alphaFrom="0.6" alphaTo="0.2"

            blurXFrom="0.0" blurXTo="50.0"

            blurYFrom="0.0" blurYTo="50.0"

            color="0xffffff"/>

    duratuion 是特效的时间 1000 毫秒

    alphaFrom 是透明度从 0.6 开始

    alphaTo 是透明度到 0.2

    blurXFrom 是X放向的模糊开始位置(相对于控件的)

    blurXTo 是X放向的模糊结束位置(相对于控件的)

    blurYFrom 是Y放向的模糊开始位置(相对于控件的)

    blurYTo 是Y放向的模糊结束位置(相对于控件的)

    color 是发光的颜色

         

    2:Sequence (顺序) Bounce(弹跳)

    代码:

    import mx.effects.easing.*;

    <mx:Sequence id="movePauseMove">

            <mx:Move yBy="-150" duration="1000" easingFunction="Bounce.easeOut"/>

            <mx:Move yBy="150" duration="1000" easingFunction="Bounce.easeIn"/>

        </mx:Sequence>

    yBy 是作用在Y方向。

    duratuion 是特效的时间 1000 毫秒

    easingFunction 是松开动作

    Bounce.easeOut 是跳出的动作

    Bounce.easeIn 是跳回的动作

    作用到控件:

    <mx:Image source="../assets/zh_cn_ptn_090722.png" 

    mouseDownEffect="{movePauseMove}"

    id="image4"/>

    自定义效果:

          每个效果都是由两个元素组成的,分别是EffectInstance效果实例与Effect类工厂。所以在自定义效果的时候,也要成对的创建这两个类的子类,并分别继承自EffectInstance类和Effect类。如:

    [java] view plaincopy
     
    1. public class TestEffect extends Effect     
    2.     {     
    3.         public var alp:Number;     
    4.         public var col:uint;     
    5.         public function TestEffect(target:Object=null)     
    6.         {     
    7.             super(target);     
    8.             instanceClass = TestInstance;     
    9.         }     
    10.              
    11.         override protected function initInstance(instance:IEffectInstance):void{     
    12.             super.initInstance(instance);     
    13.             TestInstance(instance).col = this.col;     
    14.             TestInstance(instance).alp = this.alp;     
    15.         }     
    16.     }     
    17.      
    18.      
    19.      
    20. public class TestInstance extends EffectInstance     
    21.     {     
    22.              
    23.         public var alp:Number;     
    24.         public var col:uint;     
    25.              
    26.         public function TestInstance(target:Object)     
    27.         {     
    28.             super(target);     
    29.         }     
    30.              
    31.         override public function play():void{     
    32.             super.play();     
    33.             (target as DisplayObject).alpha = this.alp;     
    34.             var shape:FlexShape = new FlexShape();     
    35.             shape.graphics.beginFill(col,1.0);     
    36.             shape.graphics.drawRect(0,0,(target as DisplayObject).width,(target as DisplayObject).height);     
    37.             shape.graphics.endFill();     
    38.             var uiComp:UIComponent = new UIComponent();     
    39.             uiComp.addChild(shape);     
    40.             UIComponent(target).addChild(uiComp);     
    41.         }     
    42.     }     
    [java] view plaincopy
     
    1. public class TestEffect extends Effect  
    2.         {  
    3.                 public var alp:Number;  
    4.                 public var col:uint;  
    5.                 public function TestEffect(target:Object=null)  
    6.                 {  
    7.                         super(target);  
    8.                         instanceClass = TestInstance;  
    9.                 }  
    10.                   
    11.                 override protected function initInstance(instance:IEffectInstance):void{  
    12.                         super.initInstance(instance);  
    13.                         TestInstance(instance).col = this.col;  
    14.                         TestInstance(instance).alp = this.alp;  
    15.                 }  
    16.         }  
    17.   
    18.   
    19.   
    20. public class TestInstance extends EffectInstance  
    21.         {  
    22.                   
    23.                 public var alp:Number;  
    24.                 public var col:uint;  
    25.                   
    26.                 public function TestInstance(target:Object)  
    27.                 {  
    28.                         super(target);  
    29.                 }  
    30.                   
    31.                 override public function play():void{  
    32.                         super.play();  
    33.                         (target as DisplayObject).alpha = this.alp;  
    34.                         var shape:FlexShape = new FlexShape();  
    35.                         shape.graphics.beginFill(col,1.0);  
    36.                         shape.graphics.drawRect(0,0,(target as DisplayObject).width,(target as DisplayObject).height);  
    37.                         shape.graphics.endFill();  
    38.                         var uiComp:UIComponent = new UIComponent();  
    39.                         uiComp.addChild(shape);  
    40.                         UIComponent(target).addChild(uiComp);  
    41.                 }  
    42.         }  

          1)当想手动播放某效果时,调用效果实例的play方法即可,为了稳定,一般在调用play方法前先调用一下end,来保证先前效果已结束。

          2) 当给对象添加触发效果方式时:uicompnent.setStyle("触发方式",特效对象);

          3)运用组合效果(Sequence与Parallel)时,调用该效果的addChild方法即可,将子效果添加的组合效果对象中。如:

                

    [java] view plaincopy
     
      1. Sequence.addChild(move);  
      2. Sequence.addChild(glow);  
  • 相关阅读:
    Android中xml解析
    [转]谈谈Java中"=="与"equals()"
    Java多线程之interrupt()的深度研究
    android:inputType参数类型说明
    Android中不能在子线程中更新View视图的原因
    美团2017秋招笔试题 拼凑钱币
    关于springmvc json交互产生的406错误
    Redis事务
    java 访问剪切板(读取与设置)
    Ajax之跨域访问与JSONP
  • 原文地址:https://www.cnblogs.com/regalys168/p/4094857.html
Copyright © 2011-2022 走看看