xparrot Posted October 6, 2014 Posted October 6, 2014 I'm new to green sock, but very well versed in Flash and ActionScript. I cannot for the life of my get an onComplete to work. Here is my code, maybe I have it in the wrong place?: function RedWineBounce04(event:TweenEvent):void { TweenMax.to(mcRedWines, tweenSpeedBounce, {bezier:{type:"quadratic", values:[{x:X_02_RedWines, y:Y_02_RedWines}, {x:(X_02_RedWines+BounceDistance), y:(Y_02_RedWines-BounceDisplacement)}, {x:(X_02_RedWines+125), y:Y_02_RedWines}], ease:Linear.easeNone, onComplete:MadeIt}}); X_02_RedWines = X_02_RedWines + 125; function MadeIt(event:TweenEvent):void { trace("Made It"); } }
Carl Posted October 6, 2014 Posted October 6, 2014 Hi and welcome to the GreenSock forums. It appears you have your onComplete and ease property as part of the object that gets passed to the BezierPlugin. You just need to move them outside that object as shown below TweenMax.to(mcRedWines, tweenSpeedBounce, {bezier:{type:"quadratic", values:[{x:X_02_RedWines, y:Y_02_RedWines}, {x:(X_02_RedWines+BounceDistance), y:(Y_02_RedWines-BounceDisplacement)}, {x:(X_02_RedWines+125), y:Y_02_RedWines}]}, ease:Linear.easeNone, onComplete:MadeIt});
xparrot Posted October 6, 2014 Author Posted October 6, 2014 If do that, I get this error: ArgumentError: Error #1063: Argument count mismatch on MethodInfo-308(). Expected 1, got 0. at Function/http://adobe.com/AS3/2006/builtin::apply() at com.greensock::TweenMax/render() at com.greensock.core::SimpleTimeline/render() at com.greensock.core::Animation$/_updateRoot()
Carl Posted October 6, 2014 Posted October 6, 2014 That error has to do with the fact that your madeIt() function is expecting a TweenEvent and its not getting one. Your error does though confirm that madeIt() is being called now. When using callbacks like onComplete a TweenEvent is not passed to the callback. You need to use onCompleteListener as listed in the docs (which is different than onComplete) onCompleteListener : Function [AS3 only] - A function that should be called (and passed an event parameter) each time the tween completes. Identical to onComplete except that the function will always be passed an event parameter whose target property points to the tween. It's the same as doing myTween.addEventListener("complete", myFunction);. Unless you need the event parameter, it's better/faster to use onComplete. Also if you want to add event listeners after a tween is created you can use addEventListener
xparrot Posted October 6, 2014 Author Posted October 6, 2014 I looked at onCompleteListener and tried that too. This is the error I get when using onCompleteListener: TypeError: Error #1034: Type Coercion failed: cannot convert com.greensock.events::TweenEvent@53efcf61 to fl.transitions.TweenEvent. at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at com.greensock::TweenMax/render() at com.greensock.core::SimpleTimeline/render() at com.greensock.core::Animation$/_updateRoot()
Carl Posted October 6, 2014 Posted October 6, 2014 Are you using import fl.transitions.TweenEvent; somewhere in your code? Do you need to be? Perhaps auto complete put that in. I would remove it if is there and it isn't absolutely necessary for your project as it appears to be causing a problem with our TweenEvent. If that doesn't fix it, please post a zip of your file (as simplified as possible to replicate the error) so that we can compile it and dig deeper. thanks
xparrot Posted October 6, 2014 Author Posted October 6, 2014 I am tweening the Adobe way throughout the rest of my animation so I need that transition. So I can't use green sock with that transition in place?
xparrot Posted October 6, 2014 Author Posted October 6, 2014 Is there any other way to call a function that'll work with that fl.transition in place?
Carl Posted October 6, 2014 Posted October 6, 2014 Yes, if you need to simply call a function and you don't need the TweenEvent for inspection just use an onComplete callback TweenMax.to(mcRedWines, tweenSpeedBounce, {bezier:{type:"quadratic", values:[{x:X_02_RedWines, y:Y_02_RedWines}, {x:(X_02_RedWines+BounceDistance), y:(Y_02_RedWines-BounceDisplacement)}, {x:(X_02_RedWines+125), y:Y_02_RedWines}], ease:Linear.easeNone, onComplete:MadeIt}}); X_02_RedWines = X_02_RedWines + 125; //note callbacks don't need events passed in function MadeIt():void { trace("Made It"); } please let us know if that works. I haven't yet investigated using both fl.transitions.TweenEvent and our TweenEvents... nor do I recall in any issues in the past. However if I find some info I will let you know.
GreenSock Posted October 6, 2014 Posted October 6, 2014 Those constants simply resolve to strings anyway, so you could just plug those in. For example, GreenSock's TweenEvent.COMPLETE is simply "complete", so you can do: tween.addEventListener("complete", yourFunction); The same goes for Flash's built-in one. TweenEvent.MOTION_FINISH is just "motionFinish".
xparrot Posted October 6, 2014 Author Posted October 6, 2014 Thank you, that did the trick. Another, DUH, moment for me. Appreciate the help
Carl Posted October 6, 2014 Posted October 6, 2014 No worries. This wasn't exactly a common problem. Good luck with the rest of your project! 1
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