# Help with listeners

**URL:** <https://forum.kirupa.com/t/help-with-listeners/244440>\
**Category:** Uncategorized\
**Created:** [November 18, 2007, 4:05am UTC](https://forum.kirupa.com/t/help-with-listeners/244440 "2007-11-18T04:05:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceflyin](https://avatars.discourse-cdn.com/v4/letter/i/9de053/32.png) [@iceflyin](https://forum.kirupa.com/u/iceflyin)\
**Post date:** [November 18, 2007, 4:05am UTC](https://forum.kirupa.com/t/help-with-listeners/244440/1 "2007-11-18T04:05:53Z")

</div>

For the life of me… I can’t get listeners to work, what is going wrong here? I get this error…

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at player$iinit()  
at game$iinit()

```auto

package {
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.events.Event;
    import flash.events.KeyboardEvent;

    public class player extends Sprite {
        private var speed = Math.random() *2+2;
        private var timer:Timer = new Timer(30);

        public function player() {
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.start();
            stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);

        }

        private function reportKeyDown(event:KeyboardEvent):void {
            trace("Key Pressed: " + String.fromCharCode(event.charCode) + 
                    " (character code: " + event.charCode + ")");
        }

        private function onTimer(event:TimerEvent):void {

        }
    }
}

```
