Idans Posted December 5, 2011 Share Posted December 5, 2011 Hi, I wrote this in order to change a color of button when the mouse is on it and to reverse it to the original color when the mouse moves out of it: import com.greensock.*; import flash.events.MouseEvent; btn_mc.addEventListener(MouseEvent.MOUSE_OVER, myClickReaction); btn_mc.addEventListener(MouseEvent.MOUSE_OUT, myOutReaction); function myClickReaction (e:MouseEvent):void{ var myTween:TweenMax = new TweenMax(e.currentTarget, 1, {tint:0x33ff00}); } function myOutReaction (e:MouseEvent):void{ myTween.reverse(); } what did I do wrong? Thank you Link to comment Share on other sites More sharing options...
X10 Posted December 5, 2011 Share Posted December 5, 2011 Hi Idans, I'm not entirely sure why that doesn't work, I'm sure Jack or Carl or someone a little more versed can explain, however try this code instead for your MOUSE_OUT function: function myOutReaction (e:MouseEvent):void{ TweenMax(e.currentTarget, 1, {tint:null}); } Link to comment Share on other sites More sharing options...
Idans Posted December 5, 2011 Author Share Posted December 5, 2011 Hi x10, thank you, but it doesn't work Link to comment Share on other sites More sharing options...
Carl Posted December 5, 2011 Share Posted December 5, 2011 Idans, since you declared myTween inside myClickReaction(), you can't access it inside myOutReaction(). you could try import com.greensock.*; import flash.events.MouseEvent; btn_mc.addEventListener(MouseEvent.MOUSE_OVER, myClickReaction); btn_mc.addEventListener(MouseEvent.MOUSE_OUT, myOutReaction); var myTween:TweenMax; function myClickReaction (e:MouseEvent):void{ myTween = new TweenMax(e.currentTarget, 1, {tint:0x33ff00}); } function myOutReaction (e:MouseEvent):void{ myTween.reverse(); } X10, your code should have been: TweenMax.to(e.currentTarget, 1, {tint:null}) that should work fine, but it will create a new tween and not reverse the existing tween with the same timing. Link to comment Share on other sites More sharing options...
X10 Posted December 5, 2011 Share Posted December 5, 2011 Ah yes, typo on my part there!! I will proof read my responses better next time. Of course it should work if the var is defined outside the function - completely missed that, hence the typo I guess! Thanks Carl! Link to comment Share on other sites More sharing options...
Idans Posted December 5, 2011 Author Share Posted December 5, 2011 It worked, Thanks 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