My meter looks great and the needle rotates in a loop. How do I add easing to it?
The meter is built from a timer event. I want the needle to bounce at the end. Rather than just adding a variable, I need some control of when it happens so I can adjust it with the animation.
WORKING CODE "Thxs to member"
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
}
FAILED ATTEMPT "needle's crazy, it's just suppose to bounce"
//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;
}
EXPERIMENT
My project will requires a higher understanding of timer events and tweening. If I can get this animation to do stuff, I think I can better understand how to pass function calls and set up events.