# AS3 rollover, rollout and click.

**URL:** <https://forum.kirupa.com/t/as3-rollover-rollout-and-click/634358>\
**Category:** programming\
**Created:** [March 19, 2016, 3:08am UTC](https://forum.kirupa.com/t/as3-rollover-rollout-and-click/634358 "2016-03-19T03:08:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wesley2905](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@wesley2905](https://forum.kirupa.com/u/wesley2905)\
**Post date:** [March 19, 2016, 3:08am UTC](https://forum.kirupa.com/t/as3-rollover-rollout-and-click/634358/1 "2016-03-19T03:08:16Z")

</div>

Hello Everyone. Im learning Flash along with AS3. Im making a menu for flash website asignment which includes 5 movieclips (mc) with build-in _rollover_, _rollout_ and _click animation_. It seems not to work as all (mc) can’t play _click animation_ nor hold _rollover animation_ (if i use\* rollover animation\* for _click animation_).

Besides, there is a problem that whenever I move my cursor over a mc, it keeps playing _rollover animation_ ( I did solve the problem by **removeevenlistener rollover** when rollover function being executed and add it again when rollout function runs ).I think this may cause the problem i listed above.

Here is my code:

var M =[tc1\_mc,tc2\_mc,tc3\_mc,tc4\_mc,tc5\_mc];

for(var i=0; i\<5; i++) {  
var Me=M[i];  
Me.addEventListener(MouseEvent.CLICK, Click);  
Me.addEventListener(MouseEvent.ROLL\_OVER, RO);  
Me.addEventListener(MouseEvent.ROLL\_OUT, RU);  
}

var Be=tc1\_mc;  
var Cur;  
Be.gotoAndPlay(63);  
Be.mouseEnabled=false;

function Click(evt:MouseEvent):void {  
if (Be) {Be.gotoAndPlay(34);  
Be.mouseEnabled=true;  
Be.addEventListener(MouseEvent.ROLL\_OUT, RU);  
Be.addEventListener(MouseEvent.ROLL\_OVER, RO);  
}

```
Cur=evt.target;
Cur.gotoAndPlay(63);
Cur.mouseEnabled=false;
Cur.removeEventListener(MouseEvent.ROLL_OUT, RU);
Cur.removeEventListener(MouseEvent.ROLL_OVER, RO);

Be=Cur;

```

}  
function RO(evt:MouseEvent):void {  
evt.target.gotoAndPlay(6);  
evt.target.removeEventListener(MouseEvent.ROLL\_OVER, RO);  
}  
function RU(evt:MouseEvent):void {  
evt.target.gotoAndPlay(34);  
evt.target.addEventListener(MouseEvent.ROLL\_OVER, RO);  
}

_with_ Be: before; Cur : current target; 6, 34 , 63 : Rollover, Rollout, Click animation begining frame respectively. ( i did create label keyframe in a new layer within the mc with RO, RU and Click , when i click something, this error : ArgumentError : Frame label Click not found in scene Click at Maintimeline/Click() and at movieclip/gotoAndPlay() )

Here is the mc design:

 ![](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/2X/6/67c2e9eaf65865c708767daa33bae78302ce89df.png)

Here is my file (no virus):  
[http://www.mediafire.com/download/23zxjiag2dks6u5/Untitled-1.fla](http://www.mediafire.com/download/23zxjiag2dks6u5/Untitled-1.fla)

Thanks all in advance and SORRY FOR MY BAD ENGLISH (im not native). Have a nice day ahead!

---

<div class="post-metadata">

**Author:** ![wesley2905](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@wesley2905](https://forum.kirupa.com/u/wesley2905)\
**Post date:** [March 19, 2016, 11:26am UTC](https://forum.kirupa.com/t/as3-rollover-rollout-and-click/634358/2 "2016-03-19T11:26:46Z")

</div>

Thank you guys for taking a look. I’ve solved my problems but i dont know how to delete this topic.
