【发布时间】:2010-02-08 16:46:09
【问题描述】:
我的仪表看起来很棒,指针会循环旋转。如何为其添加缓动?
仪表是根据计时器事件构建的。我希望针在最后反弹。我需要控制它何时发生,而不是仅仅添加一个变量,以便我可以通过动画对其进行调整。
alt text http://www.ashcraftband.com/myspace/videodnd/icon8.jpg
工作代码“感谢会员”
var timer:Timer = new Timer(20, 30);//tick 200, 36<br>
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, startAgain);
timer.start();
function startAgain($evt:TimerEvent):void {
timer.reset();
timer.start();
}
function onTimer($evt:TimerEvent):void {
watch.hand.rotation = 30 + timer.currentCount;//tick 5
}
失败的尝试“针疯了,它只是想弹跳”
//the "tick" may mess up the effect
import fl.transitions.Tween;
import fl.transitions.easing.*;
var timer:Timer = new Timer(20, 30);//tick 200, 36
var startValue:Number = watch.hand.rotation;
var finishValue:Number = 33;//400
var duration:Number = 222;//3
var myTween:Tween = new Tween(watch.hand, "rotation", Elastic.easeOut, startValue, finishValue, duration, false);//true
myTween.looping = true;
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, startAgain);
timer.start();
function startAgain($evt:TimerEvent):void {
timer.reset();
timer.start();
}
function onTimer($evt:TimerEvent):void {
watch.hand.rotation = 30 + timer.currentCount;//tick 5
//watch.x =+ 66;
}
实验
我的项目需要对定时器事件和补间有更高的理解。如果我能让这个动画做一些事情,我想我可以更好地理解如何传递函数调用和设置事件。
【问题讨论】:
标签: flash actionscript-3