# Help with class

**URL:** https://forum.kirupa.com/t/help-with-class/269637
**Category:** flash
**Created:** [August 29, 2008, 10:09pm UTC](https://forum.kirupa.com/t/help-with-class/269637 "2008-08-29T22:09:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ismael\_92](https://avatars.discourse-cdn.com/v4/letter/i/c57346/32.png) [@Ismael\_92](https://forum.kirupa.com/u/Ismael_92)
#### Post date: [August 29, 2008, 10:09pm UTC](https://forum.kirupa.com/t/help-with-class/269637/1 "2008-08-29T22:09:28Z")

</div>

Hi there, I have a problem with a class, I don’t know how to make it work, mainly because I’m new at using classes.

This is the class _sounds.as_:

```auto
package {
    import flash.events.*;
    import flash.media.Sound;
    import flash.media.SoundChannel;

    public class sounds {
        public function sounds():void {
            addEventListener(KeyboardEvent.KEY_DOWN, keys);
            trace("class is working")
        }
        public function keys(e:KeyboardEvent):void {
            if (e.keyCode == 37) {
                trace("pressed");
            }
        }
    }
}

```

I know you may think it has nothing to do with sounds, but I’m just testing it before putting the real code. And the _keys_ functions is because I will need to do something with keys so I’m just testing it.

My problem is:  
If I put **import sounds;** in the main timeline, nothing happens. If I put **sounds.sounds()** (so the _sounds_ function located inside the _sounds_ class is called) I have a compiler error which says:

_1180: Call to a possible undefined method addEventListener_  
The source is _addEventListener(KeyboardEvent.KEY\_DOWN, keys);_

So basically, what I need is to make the class work. I mean, how to import it and solve that compiler error.

Thanks a lot.
