It's not a very long code, although it can be really useful for games, for example ogres walking, rocks falling from the sky, etc...
Just paste this code on the frame you want to be shakey.
var XX:Number = 20; //Feel free to change.
var YY:Number = 20; //Feel free to change.
var startshake:Boolean = false;
var shakeavailable:Boolean = true;
_root.onEnterFrame = function(){
function shakescreen(){
if(shakeavailable){
startshake = true;
X = random(XX) - XX / 2;
Y = random(YY) - YY / 2;
_root._x += X;
_root._y += Y;
}else{
}
}
shakescreen();
}
And this on the frame where you want it to stop shaking.
_root._x = 0;
_root._y = 0;
shakeavailable = false;
