Ulysses Posted May 7, 2015 Share Posted May 7, 2015 I can't for the life of me work out how to shake a MovieClip on rollover. As I need the MovieClip to start and end in the same x/y position, the tweens don't seem to work. is there a workaround for this? Link to comment Share on other sites More sharing options...
Carl Posted May 8, 2015 Share Posted May 8, 2015 Hi and welcome to the GreenSock forums, There are quite a few ways to do this depending on your requirements. Does the shake repeat inifinitely as long as the mouse is over the mc? Does it need to abruptly snap back to position when you roll off? I'll assume you just need a simple short shake on rollover like this: http://greensock.com/forums-support-files/shake/shake.html A RoughEase will handle the shake: http://greensock.com/roughease Here is the code: import com.greensock.*; import com.greensock.easing.*; import flash.events.MouseEvent; mc.addEventListener(MouseEvent.ROLL_OVER, over); mc.startX = mc.x // record starting x value function over(e:MouseEvent):void{ TweenLite.to(mc, 0.5, {x:"+=3", ease:RoughEase.ease.config({strength:20, points:80 }), onComplete:function(){ //return mc back to startX when tween is done mc.x = mc.startX; } });} shake_cc_fla.zip 1 Link to comment Share on other sites More sharing options...
Ulysses Posted May 8, 2015 Author Share Posted May 8, 2015 That is exactly what I needed to work from Carl. Thank you very much. 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