Share Posted May 5, 2020 Hello, i created a timeline and want to access each tween individually. How can i do it? Furthermore i want to add a general function to the end of each tween. I used .add() after each tween, but is there another way to solve this? Thank you in advance. Regards Daniel Link to comment Share on other sites More sharing options...
Share Posted May 5, 2020 It sounds like you're looking for timeline.getChildren() 3 Link to comment Share on other sites More sharing options...
Author Share Posted May 6, 2020 Thank you. const tweens = timeline.getChildren(); for(var i = 0; i < tweens.length; i++) { if(tweens[0].progress() === 1){ console.log('hit'); } } Here, i wanted to console log , after the the first tween of the timeline ends. What i am doing wrong? Link to comment Share on other sites More sharing options...
Share Posted May 6, 2020 1 hour ago, Daniel2024 said: Here, i wanted to console log , after the the first tween of the timeline ends. What i am doing wrong? That loop will run immediately when invoked and since it is likely running before the end of the tween finished, the tween's progress won't be 1. But even if it was ran after the tween completed it wouldn't fire right after the tween completes, it'd just fire whenever the loop is ran. What you want to use instead is a callback, specifically the onComplete callback for the tween. If you can, it's generally more convenient to add the callback when you create the tween: .to(elem, {..., onComplete: () => console.log("hit") }) But you can add it later if you need to by using eventCallback(): timeline.getChildren()[0].eventCallback("onComplete", () => console.log('hit') ); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now