Jump to content
GreenSock

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

Timelinelite to stagger function calls on an array of objects.

Recommended Posts

I'm wondering if there is a way i can use Timelinelite and insertMultiple to stagger function calls on objects in an array maybe with dellaycall? Each object in the array has the same public start(); function. I could do this with the timer class and a loop but im wondering if there is a way to use timelinelite to have improved sequencing control. 

 

Sorry i don't have a code example of what im trying to do. 

 

Is this crazy talk or am is this a good idea?

 

thanks!

Link to comment
Share on other sites

Sure you could use the new add() method to add multiple, evenly-spaced callbacks to a timeline:

 

import com.greensock.*;


var tl = new TimelineMax({repeat:2, yoyo:true});

//there will be 1 second between each function call
tl.add([function1, function2, function3, function4], 0, "sequence", 1)


function function1(){
  trace("function1");
}


function function2(){
  trace("function2");
}


function function3(){
  trace("function3");
}


function function4(){
  trace("function4");
}

insertMultiple(), appendMultiple(), append() and insert() have been deprecated.

Lots of good stuff in the TimelineLite docs

Link to comment
Share on other sites

Thanks Carl,

 

You are always super helpful. I need to do some catching up as I was still using v.11

The .add() method looks very useful.

By the way I signed up for the talk you are giving next tuesday which is two blocks from my office. I'm looking forward to it, see you then.

 

B

  • Like 1
Link to comment
Share on other sites

Hey, B.

 

Glad to hear you will be attending the seminar. See you then!

 

-Carl

Link to comment
Share on other sites

  • 2 years later...

what if I need to pass a parameter to a function call?

 

would it look like tl.add(["function1(value)", function2, function3, function4], 0, "sequence", 1) ?

Link to comment
Share on other sites

Hi Macarrier,

 

Welcome to the forums. It sounds like you need TimelineLite.call()

myTimeline.call(myFunction, ["param1", "param2"]);

add() doesn't support passing params to functions.

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.
×