Slowing down looping animation as3

639 views Asked by At

This is the first time I've ever posted in a forum, so thanks in advance for anyone who takes the time to read/answer this question.

What I'm trying to create is basically a flipping coin animation, which starts off turning very fast and then slows down to stop with a (randomly generated) side facing upwards after about 8 seconds.

I've done the animation of a complete flip, which lasts about half a second, and made it in to a movieclip... now I'm stuck!

Any ideas how I might go about doing this in actionscript3?

2

There are 2 answers

3
HarryT On

The fastest way around this would be to use some very basic actionscript. First, create 2 animations (One heads, one tails). Now, you only need a single frame for this and don't need to place the movieclips on the stage. Use the following or similar code:

var whichSide:int = 0;
var coin1:coinAnimation1 = new coinAnimation1();
var coin2:coinAnimation2 = new coinAnimation2();

whichSide = math.Round(math.Random(1));

if(whichSide == 1)
{
addChild(coin1);
}
else
{
addChild(coin2);
}

Just don't forget to right click the movieclip and export for actionscript, giving the movieclips the class of: coinAnimation1 and coinAnimation2.

Hope this helps.

0
CGBe On

I've accomplished such animation on ´Keyframes´ using the Tweener class. You can easily tween on the keyframe parameter with specific transition...

Basic example:

Tweener.addTween(myMovieClip, {_frame:10, time:2.5});

More information about Tweener here