# \[As3\]A little problem

**URL:** https://forum.kirupa.com/t/as3-a-little-problem/277983
**Category:** Uncategorized
**Created:** [December 19, 2008, 3:58pm UTC](https://forum.kirupa.com/t/as3-a-little-problem/277983 "2008-12-19T15:58:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)
#### Post date: [December 19, 2008, 3:58pm UTC](https://forum.kirupa.com/t/as3-a-little-problem/277983/1 "2008-12-19T15:58:41Z")

</div>

```auto

package
{
    import flash.display.*;
    import flash.events.*;
    
    public class player extends MovieClip
    {
        public function player(){}
        
        public function init()
        {
            var hp:int = 100;
            var lives:int = 3;
            var current_weapon:int = 1;
            
            stage.addEventListener(KeyboardEvent.KEY_DOWN,enterKey);
            trace("done");
        }
        
        private function enterKey(e:KeyboardEvent)
        {
            trace("here");
        }
    }
}

```

on the main timeline i have a MC called “game”, inside it i am dynamically attaching the “player” mc, and the above code is the code of that player. But now the problem is, when i use the above way, everything works fine, but if i use addEventListener instead of stage.addEventListener, “here” isn’t being traced…why?

I mean whether i attach the listener to the mc “player” or the stage shouldn’t matter, right? sorry, i am totally confused here…
