Place this function on the main timeline:
- Code: Select all
function shake_mc(mc, intensity, origx, origy) {
mc._x = origx;
mc._y = origy;
mc.onEnterFrame = function() {
mc._x = origx+Math.random()*intensity;
mc._y = origy+Math.random()*intensity;
if (intensity>0) {
intensity--;
}
};
}
Then add this code to the movie clip you wish to shake - you needn't put the on(press) part if you don't want to but make sure you put it call to the shake somewhere and the origpos part in as this will make the movie clip ultimately return to its original position.
The number 5 represents the intensity of the shake and it will decrease in intensity from that number.
- Code: Select all
onClipEvent (load) {
origpos = {x:_x, y:_y};
}
on (press) {
_root.shake_mc(this, 5, origpos.x, origpos.y);
}


