# TypeError: Error #2007, when initializing ENTER\_FRAME function with dynamic MCs

**URL:** <https://forum.kirupa.com/t/typeerror-error-2007-when-initializing-enter-frame-function-with-dynamic-mcs/295461>\
**Category:** flash\
**Created:** [August 30, 2009, 11:42pm UTC](https://forum.kirupa.com/t/typeerror-error-2007-when-initializing-enter-frame-function-with-dynamic-mcs/295461 "2009-08-30T23:42:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjckls](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjckls](https://forum.kirupa.com/u/fjckls)\
**Post date:** [August 30, 2009, 11:42pm UTC](https://forum.kirupa.com/t/typeerror-error-2007-when-initializing-enter-frame-function-with-dynamic-mcs/295461/1 "2009-08-30T23:42:13Z")

</div>

I have three dynamically created MCs on stage and when I press on first one I want to initialize ENTER\_FRAME function , but Im getting this error:

```php
TypeError: Error #2007: Parameter listener must be non-null.
    at flash.events::EventDispatcher/addEventListener()
    at dynamic_buttons_fla::MainTimeline/onUp()

```

Here is my code:  
[LEFT]

```php
var button:Array = new Array();

for (var i:int = 0; i < 3; i++)
{
    var btn:MovieClip = new Btn();
    btn.y = i*(btn.height + 2);
    btn.x = 0;
    button* = btn;
    addChild(btn);
    btn.addEventListener(MouseEvent.MOUSE_UP, onUp);
}
function onUp(e:MouseEvent):void{
    switch (e.currentTarget){
        case button[0] :
            addEventListener(Event.ENTER_FRAME, onLoop); // THIS IS CAUSING ERROR
            function onLoop(e:Event):void{
                trace("loop");
            }
            break;
        case button[1] :
            trace("b2");
            break;
        case button[2] :
            trace("b3");
            break;
    }
}

```

Why i’m getting this _Parameter listener must be non-null_. I don’t understand which listener could be null. Buttons? But they can’t be null coz they are listening to other events apart from ENTER\_FRAME.  
How can I trigger ENTER\_FRAME function in this case?  
Thank you  
[/LEFT]
