Share Posted August 4, 2015 Hello, I'm new to GSAP and have only begun to use it so this will probably be a pretty simple question. I didn't know what terms to search on, but it's probably been asked in the past. I am using a for loop to create a set of training module display objects (ModuleWindow). They all contain unique content, and they all must start out offscreen, at y=stage.stageHeight+10. When the user clicks a menu button, the appropriate module needs to tween up so it's visible, and whatever one is visible needs to go back down (reverse). All I know how to do at the moment is create a TweenMax instance using .to, and that of course causes the display object to begin tweening immediately. So clearly this won't work: for (var i:int = 0; i < contentArray.length; i++) { var module:ModuleWindow = new ModuleWindow(contentArray[i]); addChild(module); module.y = stage.stageHeight + 10; var moduleTween:TweenMax = TweenMax.to(module, 0.5, {y:10}); } ...because I want each module to stay put until the appropriate button is clicked to bring it up. What I want to do is create a TweenMax instance that I can associate with each module (hopefully by assigning it as a get/set property of the module, such as module.tweenUpDown) and then invoke each module's TweenMax instance whenever I want. How do I do that? Thank you! Link to comment Share on other sites More sharing options...
Share Posted August 4, 2015 Sounds like you can just make the tween a property of the module and create it in a paused state like for (var i:int = 0; i < contentArray.length; i++) { var module:ModuleWindow = new ModuleWindow(contentArray[i]); addChild(module); module.y = stage.stageHeight + 10; module.moduleTween = TweenMax.to(module, 0.5, {y:10, paused:true}); } //later someModule.moduleTween.play(); //or someModule.moduleTween.reverse(); Link to comment Share on other sites More sharing options...
Author Share Posted August 4, 2015 Ah, thank you! 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