Okay, so eventually the code that finally made a MovieClip to shake is the following.
import flash.display.MovieClip;
import flash.events.Event;
function shake(which:MovieClip, power:Number, count:int = -1):void {
if (!which) return;
unshake(which);
which.preset = {x: which.x, y: which.y, power: power, count: count};
which.addEventListener(Event.ENTER_FRAME, onShaking);
}
function unshake(which:MovieClip):void {
if (!which) return;
which.removeEventListener(Event.ENTER_FRAME, onShaking);
if (which.preset) {
which.x = which.preset.x;
which.y = which.preset.y;
which.preset = null;
}
}
function onShaking(e:Event):void {
var which:MovieClip = e.currentTarget as MovieClip;
if (!which.preset) {
unshake(which);
return;
}
var count:int = which.preset.count;
if (count > 0) {
count--;
if (count == 0) {
unshake(which);
return;
}
which.preset.count = count;
}
var power:Number = which.preset.power;
which.x = which.preset.x + Math.random() * power - power / 2;
which.y = which.preset.y + Math.random() * power - power / 2;
}
//For insertNamehere, change it to the name of the MovieClip in the properties panel
shake(insertNamehere, 10, 100);
//Thanks again Organis, you are a great help!