Jump to content
GreenSock

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

Recursive callback onComplete - play random timelines at the end of each other

Recommended Posts

Hi everyone!

I'm currently trying to create a function that plays a timeline, add to that a callback function that play another random timeline, with a callback to another etc.. (something like a recursion)

In example: In have some timelines (7/8) and I want to play them one after one completely random, endless. 
I really can't find any error, in my mind this can work but in real it doesn't. I works for the first one / two  iterations then it goes in a insanely loop

 

function playRoutes(){
  var randValue = Math.floor(Math.random() * (globeHandler.routes.length));
  var route = globeHandler.routes[randValue].timeline;
  route.timeline.eventCallback('onComplete', playRoutes);				
  route.timeline.play();
}
playRoutes();

 

 

Here is the console.log o the random value, as you can see is called very fast.

5a6b8eee98ce7_Schermata2018-01-26alle17_31_27.png.10d3be7df7cd53d3e3f53e4f686dfe65.png

 

 

Any idea?

Link to post
Share on other sites

And it looks like I'm a little late as this was already answered on slack.

  • Like 1
Link to post
Share on other sites
6 hours ago, OSUblake said:

And it looks like I'm a little late as this was already answered on slack.

Yup. Thanks anyway ;-)

Actually after the slack discussion I forgot about this question.

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.

×