flex_对象动画;
=>animationApp.mxml <?xml version="1.0" encoding="utf-8"?> =>MyComponent.as package aspackage { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.utils.Timer; import mx.core.UIComponent; public class MyComponent extends UIComponent { /** * 属性*/ /*圆*/ private var circle:Sprite; /*计时器*/ private var myTimer:Timer; /*是否已经单击*/ private var hasClick:Boolean=false; /** * 构造函数 */ public function MyComponent() { /** * 绘制圆*/ circle=new Sprite(); circle.graphics.beginFill(0x990000); circle.graphics.drawCircle(50,50,50); circle.graphics.endFill(); circle.useHandCursor=true; circle.buttonMode=true; this.addChild(circle); /*圆_侦听单击事件*/ circle.addEventListener(MouseEvent.CLICK,startAnimationFn); /*初始化计时器*/ myTimer=new Timer(2000,1); myTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerCompleteHandler); } /** * 计时函数 * @param event */ private function onTimerCompleteHandler(event:TimerEvent):void { /** * 再一次*/ circle.alpha=1; hasClick=false; } /** * 产生动画效果_圆逐渐模糊; * @param event */ private function startAnimationFn(event:MouseEvent):void { if (myTimer.running) { myTimer.reset(); } myTimer.start(); if (!hasClick) { circle.addEventListener(Event.ENTER_FRAME,fadeCircleFn); hasClick=true; } } /** * 圆逐渐模糊 * @param event * About_When this animation starts,this function is called every frame(每帧). * The change made by this function (updated to the screen every frame) is what causes the animation to occur. */ private function fadeCircleFn(event:Event):void { /*通过改变圆的alpha值,来进行逐渐模糊效果*/ circle.alpha-=.05; if (circle.alpha <= 0) { circle.removeEventListener(Event.ENTER_FRAME,fadeCircleFn); } } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |