# gotoAndPlay() problem

**URL:** <https://forum.kirupa.com/t/gotoandplay-problem/265201>\
**Category:** flash\
**Created:** [July 6, 2008, 12:08am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201 "2008-07-06T00:08:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnb816](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnb816](https://forum.kirupa.com/u/johnb816)\
**Post date:** [July 6, 2008, 12:08am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201/1 "2008-07-06T00:08:39Z")

</div>

My movie clip is acting randomly. It plays my “Over” function when the cursor is over it, however, at times it also plays the “Out” function when the cursor is still on the clip.

I think that the problem is with my code and not the movie clip itself. Can someone please help?

I’ve attached my .fla file for reference. Playing the .swf file makes me think that the movie clip is “listening” to the elements it contains inside. Could this explain why my movie clip plays the “out” frame when the mouse cursor is still over the movie clip?

> var cliparray:Array= [clip01, clip02, clip03, clip04];

for each(var clip:MovieClip in cliparray) {  
clip.addEventListener(MouseEvent.MOUSE\_OVER, Over, false, 0, true);  
clip.addEventListener(MouseEvent.MOUSE\_OUT, Out, false, 1, true);  
}

function Over(e:MouseEvent):void {  
e.currentTarget.gotoAndPlay(“over”);  
}  
function Out(e:MouseEvent):void {  
e.currentTarget.gotoAndPlay(“out”);  
}

---

<div class="post-metadata">

**Author:** ![johnb816](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnb816](https://forum.kirupa.com/u/johnb816)\
**Post date:** [July 6, 2008, 1:17am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201/2 "2008-07-06T01:17:09Z")

</div>

I’ve fixed this problem with the following changes: ROLL\_OVER instead of MOUSE\_OVER; and ROLL\_OUT instead of MOUSE\_OUT. Still, I don’t know why using “ROLL” works while using “MOUSE” does not.

On a related side question… how can I get the cursor to change to a hand when it moves over the movie clips?

---

<div class="post-metadata">

**Author:** ![johnb816](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnb816](https://forum.kirupa.com/u/johnb816)\
**Post date:** [July 6, 2008, 1:24am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201/3 "2008-07-06T01:24:04Z")

</div>

For anyone interested… I’ve attached the new .fla file that works.

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [July 6, 2008, 1:31am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201/4 "2008-07-06T01:31:09Z")

</div>

MOUSE\_OVER / OUT would also work if you set clip.mouseChildren to false.

Roughly speaking, mouseover/out also affect the clips inside your clip. Rollover/out just affects the base, and it doesn’t bubble.

---

<div class="post-metadata">

**Author:** ![johnb816](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnb816](https://forum.kirupa.com/u/johnb816)\
**Post date:** [July 6, 2008, 1:44am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201/5 "2008-07-06T01:44:08Z")

</div>

Thank you very much for your response. Everything works now–the cursor even changes its shape to a hand now.

This is the new code:

> var cliparray:Array= [clip01, clip02, clip03, clip04];

for each(var clip:MovieClip in cliparray) {  
clip.buttonMode=true;  
clip.mouseChildren=false;  
clip.addEventListener(MouseEvent.MOUSE\_OVER, Over, false, 0, true);  
clip.addEventListener(MouseEvent.MOUSE\_OUT, Out, false, 1, true);  
}

function Over(e:MouseEvent):void {  
e.currentTarget.gotoAndPlay(“over”);  
}  
function Out(e:MouseEvent):void {  
e.currentTarget.gotoAndPlay(“out”);  
}

The new file is attached.

---

<div class="post-metadata">

**Author:** ![johnb816](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnb816](https://forum.kirupa.com/u/johnb816)\
**Post date:** [July 6, 2008, 1:47am UTC](https://forum.kirupa.com/t/gotoandplay-problem/265201/6 "2008-07-06T01:47:55Z")

</div>

Oops… posted the wrong file.
