Wednesday, November 3, 2010

Timing Animation With ActionScript 3

Flex Builder 4 Flash Video Flash Video

Tween 2 Movie Clips without using the Timeline

Start a tween, and while it is playing start another one using the Timer Class and TimerEvent. First you have to import the classes, then create the timer. the Timer() constructor takes two parameters. The first parameter controls how frequently the TimerEvent.TIMER event gets dispatched (in milliseconds). The second parameter is the number of times that the TimerEvent.TIMER event will be dispatched before stopping.

import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.utils.Timer;
var timer:Timer = new Timer(1500, 1);//Creating the timer
timer.addEventListener(TimerEvent.TIMER, nextTween);

var myTweenX:Tween = new Tween(movieClip, "alpha", None.easeOut, 0, 1, 3, true);

function nextTween(e:TimerEvent):void{
var myTweenAlpha:Tween = new Tween(movieClip, "x", Strong.easeOut, 0, 300, 3, true);
timer.removeEventListener(TimerEvent.TIMER, nextTween);

ActionScript 3.0 Language Reference

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...