# Looping frame breaks mouse event

**URL:** https://forum.kirupa.com/t/looping-frame-breaks-mouse-event/321726
**Category:** Uncategorized
**Created:** [April 28, 2011, 6:27pm UTC](https://forum.kirupa.com/t/looping-frame-breaks-mouse-event/321726 "2011-04-28T18:27:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mrsnoogle](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mrsnoogle](https://forum.kirupa.com/u/mrsnoogle)
#### Post date: [April 28, 2011, 6:27pm UTC](https://forum.kirupa.com/t/looping-frame-breaks-mouse-event/321726/1 "2011-04-28T18:27:34Z")

</div>

G’day. I am quite new to action script and have run into a bit of trouble and was hoping someone was kind enough to point me in the direction I should be going.

I have a picture of a van moving on its x and y in relation to the mouse movement on screen…

stage.addEventListener(MouseEvent.MOUSE\_MOVE, mouseMovement);

function mouseMovement(e:MouseEvent):void{

```
van.x = (mouseX/20) + 490;
van.y = (mouseY/20) + 285;

```

}

… And this is working fine but the moment I add anything after frame 1 things stop working. I want to loop on frame 1 until the user clicks a button and then jumps to say frame 100 where the frame loops again until the user clicks another button and jumps to a new looped frame again. I have tired

addEventListener(Event.EXIT\_FRAME,cycle);  
function cycle(event:Event) {  
gotoAndPlay(1);  
}

```
... but this breaks the van moving on its x and y and the van jumps around weirdly when i move the mouse around. Any help I could get here would be really appriciated! 
                                                                                                                                                          ... Camm
```
