Jump to content
Search Community

Shake on Rollover

Ulysses test
Moderator Tag

Recommended Posts

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

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

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...