zoukankan      html  css  js  c++  java
  • 自己写的三个效果,一个是逐渐消失,一个是移动离开,一个是转动离开

    2009-06-19 16:26

    小菜刚上手,写了三个flex里面已经有的效果。请大家不要见笑

    package org.effect
    {
    /*
    * 渐渐消失效果
    */
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    public class Fade
    {
       private var tdisplay:Sprite;
       private var ttime:Number;
       private var setTime:Timer;
      
       public function Fade(display:Sprite,time:Number)
       {
        this.tdisplay=display;
        this.ttime=time;
       
        this.setTime=new Timer(this.ttime,30);
        this.setTime.addEventListener(TimerEvent.TIMER,onClick);
        this.setTime.addEventListener(TimerEvent.TIMER_COMPLETE,remove);
        this.setTime.start();
       }
      
       private function onClick(event:TimerEvent):void{
        this.tdisplay.alpha=(this.ttime-event.target.currentCount)/this.ttime;
       }
      
       private function remove(evt:TimerEvent):void{
        this.tdisplay.parent.removeChild(this.tdisplay);
       }

    }
    }

    package org.effect
    {
    /*
    * 移动离开效果
    */
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    public class Move
    {
       private var tdisplay:Sprite;
       private var ttime:Number;
       private var setTime:Timer;
      
       public function Move(display:Sprite,time:Number)
       {
        this.tdisplay=display;
        this.ttime=time;
       
        this.setTime=new Timer(this.ttime,30);
        this.setTime.addEventListener(TimerEvent.TIMER,onClick);
        this.setTime.addEventListener(TimerEvent.TIMER_COMPLETE,remove);
        this.setTime.start();
       }
      
       private function onClick(event:TimerEvent):void{
        this.tdisplay.x=(event.target.currentCount/this.ttime)*2000;
       }
      
       private function remove(evt:TimerEvent):void{
        this.tdisplay.parent.removeChild(this.tdisplay);
       }

    }
    }

    package org.effect
    {
    /*
    * 转动消失效果
    */
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    public class Rotation
    {
       private var tdisplay:Sprite;
       private var ttime:Number;
       private var setTime:Timer;
      
       public function Rotation(display:Sprite,time:Number)
       {
        this.tdisplay=display;
        this.ttime=time;
       
        this.setTime=new Timer(this.ttime,100);
        this.setTime.addEventListener(TimerEvent.TIMER,onClick);
        this.setTime.addEventListener(TimerEvent.TIMER_COMPLETE,remove);
        this.setTime.start();
       }
      
       private function onClick(event:TimerEvent):void{
        this.tdisplay.rotation=(event.target.currentCount/this.ttime)*180;
       }
      
       private function remove(evt:TimerEvent):void{
        this.tdisplay.parent.removeChild(this.tdisplay);
       }

    }
    }

    其实三个效果都是同一个做法,就是用timer类,让 timer每隔一定时间,修改一下对象的属性。

  • 相关阅读:
    C++ 虚函数 、纯虚函数、接口的实用方法和意义
    C++ static成员变量与static成员函数
    C++格式化输出的好东西
    const的用法,特别是用在函数前面与后面的区别!
    SAP CRM WebClient UI cross component跳转的一个具体例子
    如何用ABAP代码读取SAP Business partner的附件数据
    SAP CRM Enterprise Search initial load遇到错误该如何处理
    使用SAP WebIDE给SAP UI5应用添加data source
    使用Selenium自动化测试SAP CRM WebClient UI
    php 对象数组互转
  • 原文地址:https://www.cnblogs.com/crkay/p/1747858.html
Copyright © 2011-2022 走看看