views:

248

answers:

1

Hello.

In my as3 code using Flash cs3, everything works fine without any document class. I can use event handlers and they work. But, once I attach a document class, I start to get this error: 1046: Type was not found or was not a compile-time constant: KeyboardEvent.

Could somebody explain why this occurs? This is what my document class looks like:

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.display.MovieClip;
    import flash.geom.Point;
    import flash.geom.Matrix
    import flash.ui.Keyboard;
    import flash.Event.KeyboardEvent;
    import flash.Event.MouseEvent;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;

    public class myCoolClass extends MovieClip {

    }

}

But then, I start to get more errors. I get: 1180: Call to a possibly undefined method SoundTransform..

Do I have to keep adding more import's in order to have it run properly?

Thanks

+1  A: 

Yes - you need to import all of the classes that are used. A bunch of classes are implicitly imported when you write code on the timeline in flash but when you use classes you need to explicitly import all referenced classes.

A good IDE should do this for you automatically (e.g. press Ctrl+Shift+I in FDT - I'm pretty sure Flash Builder, Flex Builder and Flash Develop also have this sort of functionality)

vitch