barrowman

Create an array for a stagger in Flanimate

Recommended Posts

til = new TimelineMax({repeat:0, repeatDelay:0.1});
//-----------------------
var GlowingBalls = [root.Lights.GlowBall1, root.Lights.GlowBall2, root.Lights.GlowBall3,
root.Lights.GlowBall4, root.Lights.GlowBall5, root.Lights.GlowBall6, root.Lights.GlowBall7,
root.Lights.GlowBall8, root.Lights.GlowBall9, root.Lights.GlowBall10, root.Lights.GlowBall11,
root.Lights.GlowBall12, root.Lights.GlowBall13, root.Lights.GlowBall14, root.Lights.GlowBall15,
root.Lights.GlowBall16, root.Lights.GlowBall17, root.Lights.GlowBall18, root.Lights.GlowBall19,
root.Lights.GlowBall20];
//-----------------------
til. .staggerTo(GlowingBalls, 0.75, {alpha:0.1, ease:Bounce.easeInOut, overwrite: false, repeat:30, yoyo:true}, 0.12, 0)

 

Is there a way to make this array simpler and more flexible? Right now it works pretty much as it should in the Stagger. But if I needed to add another 40-odd glowing balls for example, it might be a little cumbersome.

 

In the old AS days you could create a [n] type thing, and create an array up to a value you specified, but I'm more than rusty on AS, which translates to pretty much clueless on how to do this in JS for Flanimate to work with Greensock. 

 

Thanks again

 

Share this post


Link to post
Share on other sites

Sure, maybe something like:

var a = [],
    total = 20;
for (i = 1; i <= total; i++) {
    a.push(root.Lights["GlowBall" + i]);
}
til.staggerTo(a, 0.75, ...);

 

Does that work? 

  • Like 1

Share this post


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.