# Timeline Button Instance - addEventListener scoping problem

**URL:** <https://forum.kirupa.com/t/timeline-button-instance-addeventlistener-scoping-problem/234164>\
**Category:** flash\
**Created:** [July 31, 2007, 5:49am UTC](https://forum.kirupa.com/t/timeline-button-instance-addeventlistener-scoping-problem/234164 "2007-07-31T05:49:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bzouchir](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bzouchir/32/2088_2.png) [@bzouchir](https://forum.kirupa.com/u/bzouchir)\
**Post date:** [July 31, 2007, 5:49am UTC](https://forum.kirupa.com/t/timeline-button-instance-addeventlistener-scoping-problem/234164/1 "2007-07-31T05:49:46Z")

</div>

Hi everyone,

just a small problem I encountered and would be great if we can get a good explanation on why this is happening.

I have:  
a button: btn  
inside a movie clip: mc

the btn is animated on the mc timeline.

frames:

1. this is my initial frame with stop();

2.this is when btn plays the first animation  
…  
5: stop()

6:empty keyframe

1. this is when the btn plays the second animation  
…  
10.gotoAndStop(1)

pls check below:

now here’s the code:

```auto

stop();
import flash.events.MouseEvent;
var nClicks:Number = 0;

mc.btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
	if(nClicks == 0){
		mc.gotoAndPlay("play");
		nClicks ++;
	}else{
		mc.gotoAndPlay("back");
		nClicks = 0;
	}
}

```

don’t worry abt the code much.

The first scenario “not working”, the clip plays animation one on the first click, then plays animation 2 on the second click, then at frame 10. gotoAndStop(1) and then it stops playing, as if  
onClick() doesn’t exist anymore.

but all this works fine in “working” scenario, where all i did is deleting that empty keyframe in between.

just for the curiosity, plus because i used to organize my timeline with those empty keyframes, can someone please explain why is this happening?

What is this empty keyframe doing to the btn instance?

thanks
