grimey Posted November 29, 2009 Share Posted November 29, 2009 Hey! Can TweenMax condense the syntax for functions similar to this: TweenMax.to(mc,.5,{x:10,onComplete:function() { // do something when the tween is complete; }); Some kind of of shorthand for these functions would be a great time/code saver. Thank you so much for TweenMax! It makes my customers' dreams come true! :grimey Link to comment Share on other sites More sharing options...
GreenSock Posted November 29, 2009 Share Posted November 29, 2009 Using anonymous functions like that is considered a poor coding practice, just so you know. It can cause garbage collection issues in Flash (has nothing to do with TweenLite/Max specifically) and it's just kinda ugly. There's not a shorthand way to do what you're trying to do (at least not that I know of). You should use regular functions like: TweenMax.to(mc,.5,{x:10,onComplete:onFinishTween}); function onFinishTween():void { // do something when the tween is complete; } If you're trying to sequence things, I'd highly recommend checking out the TimelineLite and TimelineMax classes which make it super easy. http://blog.greensock.com/timeline-basics/. Have fun. Link to comment Share on other sites More sharing options...
grimey Posted November 29, 2009 Author Share Posted November 29, 2009 Thanks for the info. I wasn't aware of the garbage collection problem. I'll have to rethink my strategy. My only hope was to avoid having a separate function to remove a child after it's faded out or slid off the stage or something. Link to comment Share on other sites More sharing options...
GreenSock Posted November 29, 2009 Share Posted November 29, 2009 Tip: If you're worried about having to create a function for each tween that basically does the same thing but for different targets, just use the onCompleteParams and a more generic function, like: TweenMax.to(mc,.5,{x:10,onComplete:removeTarget, onCompleteParams:[mc]}); function removeTarget(target:DisplayObject):void { target.parent.removeChild(target); } 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