# Shake effect - menu

**URL:** <https://forum.kirupa.com/t/shake-effect-menu/297768>\
**Category:** flash\
**Created:** [October 8, 2009, 6:59am UTC](https://forum.kirupa.com/t/shake-effect-menu/297768 "2009-10-08T06:59:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wotan318](https://avatars.discourse-cdn.com/v4/letter/w/a9adbd/32.png) [@wotan318](https://forum.kirupa.com/u/wotan318)\
**Post date:** [October 8, 2009, 6:59am UTC](https://forum.kirupa.com/t/shake-effect-menu/297768/1 "2009-10-08T06:59:00Z")

</div>

Hello,  
I have problem with flash or AS3, i really don’t know there the problem is. The original tuts is on this link [http://www.riacodes.com/flash/shaking-effect/](http://www.riacodes.com/flash/shaking-effect/)

The problem is when i put one more picture, the secound picture jump on mouseover above first picture ( when i go over the first and the secound picture).

Here is my AS:  
var coordX:Number = domov\_mc.x;  
var coordY:Number = domov\_mc.y;  
var coordZ:Number = storitve\_mc.x;  
var coordT:Number = storitve\_mc.y;  
var timer:Timer = new Timer(12);

domov\_mc.buttonMode = true;  
storitve\_mc.buttonMode = true;

domov\_mc.addEventListener(MouseEvent.ROLL\_OVER,sta rtShake);  
domov\_mc.addEventListener(MouseEvent.ROLL\_OUT,stop Shake);  
storitve\_mc.addEventListener(MouseEvent.ROLL\_OVER, startShake);  
storitve\_mc.addEventListener(MouseEvent.ROLL\_OUT,s topShake);  
timer.addEventListener(TimerEvent.TIMER, shakeImage);

function startShake(e:MouseEvent):void{  
timer.start ()  
}

function stopShake(e:MouseEvent):void{  
timer.stop();  
domov\_mc.x = coordX;  
domov\_mc.y = coordY;  
domov\_mc.rotation = 0;  
storitve\_mc.x = coordZ;  
storitve\_mc.y = coordT;  
storitve\_mc.rotation = 0;  
}

function shakeImage(event:Event):void {  
domov\_mc.x = coordX+ getMinusOrPlus()\*(Math.random()_2);  
domov\_mc.y = coordY+ getMinusOrPlus()_(Math.random()_2);  
domov\_mc.rotation = getMinusOrPlus()_ Math.random()_1;  
storitve\_mc.x = coordX+ getMinusOrPlus()_(Math.random()_5);  
storitve\_mc.y = coordY+ getMinusOrPlus()_(Math.random()_3);  
storitve\_mc.rotation = getMinusOrPlus()_ Math.random()\*2;  
}

function getMinusOrPlus():int{  
var rand : Number = Math.random()\*3;  
if (rand\<1) return -1  
else return 1;  
}

Here are the .swf files. [http://www.2shared.com/file/8281141/cfaa634a/flash.html](http://www.2shared.com/file/8281141/cfaa634a/flash.html)  
The single.swf is the menu with only ‘domov’ shake effect and the double.swf is with ‘domov’ and ‘storitve’, so the ‘storitve’ shake on ‘domov’.  
If someone has the solution please help me.

p.s. sorry for my bad english.
