Jump to content
Search Community

Proper way to trigger function onStart

Max test
Moderator Tag

Recommended Posts

I use TweenLite to tween Starling MovieClip objects.

 

My code looks like this:

for (var i:int = 0; i < stars.length; i++) {
   var _star:MovieClip = stars[i] as MovieClip;
   TweenLite.to(_star, 5, {x: 100, y: 100, visible: true, delay: 2 * i});
}

I want to call _star.start() for each star when it delay expires and it must start animation. Could you please show how to properly use onStart call and it's parameters?

Link to comment
Share on other sites

main timeline code

var stars = [s1, s2]

for (var i:int = 0; i < stars.length; i++) {
   var _star:MovieClip = stars[i] as MovieClip;
   TweenLite.to(_star, 5, {x: 100, y: 100, visible: true, delay: 2 * i, onStart:_star.start, onStartParams:[i]});
}

inside star

function start(index) {
trace("i started and my index is " + index ); 
}

//outputs:

i started and my index is 0 (at time 0)
i started and my index is 1 (after 2 seconds)
 
---
 

 

stars_CS5.zip

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