# Help with addEventListener()

**URL:** <https://forum.kirupa.com/t/help-with-addeventlistener/282946>\
**Category:** Uncategorized\
**Created:** [February 28, 2009, 2:39am UTC](https://forum.kirupa.com/t/help-with-addeventlistener/282946 "2009-02-28T02:39:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fluke32](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@Fluke32](https://forum.kirupa.com/u/Fluke32)\
**Post date:** [February 28, 2009, 2:39am UTC](https://forum.kirupa.com/t/help-with-addeventlistener/282946/1 "2009-02-28T02:39:31Z")

</div>

I’m trying to create a simple flash movie where I have 4 buttons, and 5 frames labeled.  
I’ve created a button B, C, D, & E, at the same time I Labeled 5 different frames with labels “A”, “B”, “C”, “D”, and “E” respectively.

Here is the code:

```auto
import flash.net.*;

gotoAndPlay("A");
function playClickHandler(event:MouseEvent):void
{ if (event.target.name == "B")
            gotoAndPlay("B");
        else if(event.target.name == "C") gotoAndPlay("C");
        else if(event.target.name == "D") gotoAndPlay("D");
        else if(event.target.name == "E") gotoAndPlay("E");
        else gotoAndPlay("A");
}

B.addEventListener(MouseEvent.CLICK, playClickHandler);
C.addEventListener(MouseEvent.CLICK, playClickHandler);
D.addEventListener(MouseEvent.CLICK, playClickHandler);
E.addEventListener(MouseEvent.CLICK, playClickHandler);

```

I always get a “Type Error: Error #1009” Error on the lines that has [object].addEventListener(); on it, and I don’t see the reason behind it as I basically just added if else statements on a previously already working script.

Thanks in advance for any help.
