Share Posted March 29, 2018 Good afternoon, imagine a number of elements that need to be tweened onto 'stage' and off 'stage' depending on the user selection. How on earth do make a call to a timeline in a function from a number of buttons? Maybe there is a better approach to my attempt in the pen line 65. Thank you for taking the time to look at this post. See the Pen qoxRYv by Joostan-33 (@Joostan-33) on CodePen See the Pen qoxRYv by Joostan-33 (@Joostan-33) on CodePen Link to comment Share on other sites More sharing options...
Share Posted March 29, 2018 I imagine this is what you're looking for: See the Pen jzZBeX?editors=0010 by GreenSock (@GreenSock) on CodePen Right? There are actually a lot of ways you could handle this - I just provided one. I attached all your animations to an "animations" object with properties named according to your functions. That makes it relatively easy to access them and call them dynamically, like animations[currScene + "out"](). I also needed to fix the way the click() events were assigned, and the logic in that function. Hopefully this gets you going in the right direction, but let us know if you need anything else. Happy tweening! 3 1 Link to comment Share on other sites More sharing options...
Author Share Posted March 29, 2018 Thank you Jack. Aha, you placed all the functions in an object to make them easier to access. I really need to learn more javascript, i find it so fiddly! Justin 2 Link to comment Share on other sites More sharing options...
Share Posted March 29, 2018 16 minutes ago, Joostan said: I really need to learn more javascript, i find it so fiddly! Nah, after a while it'll make sense. Hang in there - we all went through that season where we felt like we're running in muck trying to get anything done in JS. It'll get better. Hang around these forums and it might help accelerate the process a bit. Lots of smart people around here. Thanks for being a Club GreenSock member. Good luck with your project. 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