Jump to content
Search Community

Recommended Posts

Posted
this is my coding sample:



var timeline:TimelineMax = new TimelineMax();
timeline.staggerTo([mc1,mc2,mc3],1,{onComplete:Function}, 1);


 

i want each mc to have a different function. is it possible?

 

Posted

No, not really but you could detect what the target of tween that just complete is and then do stuff like:

 

var timeline:TimelineMax = new TimelineMax();
timeline.staggerTo([mc1,mc2,mc3],1,{x:100, onComplete:myFunction, onCompleteParams:["{self}"]}, 1);


function myFunction(tween) {


if(tween.target == mc1){
tween.target.alpha = 0.2;
}


if(tween.target == mc2){
tween.target.rotation = 45;
}


if(tween.target == mc3) {
   tween.target.scaleX = 4; 
}
}

or better yet give each object its own unique function and call it

 

var timeline:TimelineMax = new TimelineMax();
timeline.staggerTo([mc1,mc2,mc3],1,{x:100, onComplete:myFunction, onCompleteParams:["{self}"]}, 1);




mc1.done = function() {
trace("ouch")
}


mc2.done = function () {
trace("help"); 
}


mc3.done = function() {
trace("nooo"); 
}


function myFunction(tween) {
  tween.target.done();
}
Posted

The stagger functions are just wrappers around a loop, so you could do that yourself:

var targets:Array = [obj1, obj2, obj3],
    funcs:Array = [func1, func2, func3],
    stagger:Number = 1,
    time:Number = timeline.duration();
for (var i:int = 0; i < targets.length; i++) {
    timeline.to(targets[i], 1, {onComplete:funcs[i]}, time + i * stagger);
}
Posted

Thanks so much for the answer both of you!  :-)

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.
×
×
  • Create New...