var coordX:Number = shaker_mc.x; var coordY:Number = shaker_mc.y; var timer:Timer = new Timer(10);</p><p>shaker_mc.buttonMode = true;</p><p>shaker_mc.addEventListener(MouseEvent.ROLL_OVER,startShake); shaker_mc.addEventListener(MouseEvent.ROLL_OUT,stopShake); timer.addEventListener(TimerEvent.TIMER, shakeImage);
function startShake(e:MouseEvent):void{ timer.start () }function stopShake(e:MouseEvent):void{ timer.stop(); shaker_mc.x = coordX; shaker_mc.y = coordY; shaker_mc.rotation = 0; }function shakeImage(event:Event):void { shaker_mc.x = coordX+ getMinusOrPlus()*(Math.random()*5); shaker_mc.y = coordY+ getMinusOrPlus()*(Math.random()*5); shaker_mc.rotation = getMinusOrPlus()* Math.random()*6; } function getMinusOrPlus():int{ var rand : Number = Math.random()*2; if (rand<1) return -1 else return 1; }