Click the buttons to see Fred traverse along his simple path.
TimelineMax allows you to create amazing animation sequences. With the addLabel() and tweenTo() methods you can easily navigate to any part of a timeline. This simple example will open the door to a world of opportunities with much more complex animations and interactions. Let’s get started.
Watch the Video
Tips
addLabel() allows you to insert a label much like you would use a frame label in the Flash IDE. When using addLabel you simply pass in a label name and the point in time you want the label to be inserted. As shown in the video at 6:20, using the timeline’s duration property is really the way to go.
addLabel(“someLabelName”, tl.duration);
tweenTo() allows you to play the timeline from its current postion to any label. tweenTo is smart enough to know whether or not the timeline needs to play forwards or backwards. tweenTo respects all the timing and easing of every tween in the timeline.
SAMPLE AS3 CODE
var tl:TimelineMax = new TimelineMax();
tl.append(TweenMax.to(fred_mc, 1, {x:homePos_mc.x, y:homePos_mc.y, scaleX:1, scaleY:1}));
//using tl.duration dynamically generates the duration of the timeline
//based on the duration of all previous tweens.
tl.addLabel("home", tl.duration)
tl.append(TweenMax.to(fred_mc, .5, {x:schoolPos_mc.x, y:schoolPos_mc.y, scaleX:1.2, scaleY:1.2}));
tl.addLabel("school", tl.duration)
tl.append(TweenMax.to(fred_mc, .3, {x:workPos_mc.x, y:workPos_mc.y, scaleX:1.4, scaleY:1.4}));
tl.addLabel("work", tl.duration)
tl.append(TweenMax.to(fred_mc, 1, {x:moviesPos_mc.x, y:moviesPos_mc.y, scaleX:2.4, scaleY:2.4}));
tl.addLabel("movies", tl.duration)
//eventListener functions for each button
function goHome(e:MouseEvent):void{
tl.tweenTo("home")
}
function goSchool(e:MouseEvent):void{
tl.tweenTo("school")
}
function goWork(e:MouseEvent):void{
tl.tweenTo("work")
}
function goMovies(e:MouseEvent):void{
tl.tweenTo("movies")
}
Download Flash CS3 Source
SNORKL_TV_timelineMax_addLabel_tweenTo
Related Content
GreenSock.com official TimelineMax info
More TimelineMax Tutorials on Snorkl.tv
Let me know if you have any questions.
Carl






