浏览 3420 次
锁定老帖子 主题:拖动元件延时跟随的动画效果
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-02-10
最后修改:2010-02-10
/** * 实现拖动延时效果的代码 */ package { import fl.transitions.Tween; import fl.transitions.TweenEvent; import fl.transitions.easing.Strong; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.utils.Timer; public class DragEffect extends Sprite { private var regularTweenX:Tween; private var regularTweenY:Tween; private var noneTweenX:Tween; private var noneTweenY:Tween; private var goalX:Number; private var goalY:Number; [Embed(source="com/gde/assets/light.swf", symbol="Light")] private var Light :Class; private var light:*; private var timer:Timer; public function DragEffect() { //设置flash在网页缩放的时候,不缩放内部元件,而可以裁切显示内容 stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; timer = new Timer(3); timer.addEventListener(TimerEvent.TIMER, easeMoveHandler); light = new Light(); light.x = 0; light.y = 0; this.addChild(light); stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler); } private function moveHandler(e:MouseEvent):void{ goalX = e.stageX; goalY = e.stageY; timer.reset(); timer.start(); } private function easeMoveHandler(e:TimerEvent):void{ if(regularTweenY != null){ regularTweenY.stop(); } regularTweenY = new Tween(light, "x", Strong.easeOut, light.x, goalX, Math.abs(goalX - light.x)/500, true); } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-02-10
这个是ActionScript?
|
|
返回顶楼 | |
发表时间:2010-03-02
用到了fl包,其中主要用到了Tween类
|
|
返回顶楼 | |