Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
jtvalles

Repopulate TimelineMax with new clips

Recommended Posts

Hey guys. This is my first foray into TimelineMax. I'm trying to build an app that will take the same timeline and repopulate with another clip before it plays again.

 

So far, the only way I've been able to make it work throws errors.

 

Any advice?

 

var elements:Array = new Array(mc0,mc1,mc2)
var counter:Number = 0;
var tl:TimelineMax = new TimelineMax({paused:true, repeat:0});;
var mc = elements[counter];

function stopIt():void {
tl.pause();
}
stage.addEventListener(MouseEvent.CLICK, resume)

function resume(e):void {
tl.resume();
tl.to(mc, 1, {x:100, onComplete:stopIt});
tl.to(mc, 1, {x:300, onComplete:stopIt});
tl.to(mc, 1, {y:250, onComplete:stopIt}); 
counter = counter+1;
mc = elements[counter]
}

 

Link to post
Share on other sites

I wouldn't recommend trying to change the target of a tween. The target property is read-only and not meant to be changed once a tween has been constructed.

 

One thing you could do is swap children of the target. So if your tween is tweening mc, perhaps you can run a function that removes a child from mc and then adds a new one.

 

In cases like this I would normally suggest that each time you need a new target you run a function that calls clear() on your timeline and you rebuild it with new tweens with new targets.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×