views:

61

answers:

1

Hello,

I download an AS3 package and I'm trying to add an eventListener to it. I'm adding this event in inline code. But I get the following error:

1046: Type was not found or was not a compile-time constant: MouseEvent.

Since I don't know how to write classes, my question is: Can I write inline code when the document has a class assigned to it? If so, why am I getting the above error?

+1  A: 

Did you

import flash.events.MouseEvent;

?

superjoe30
Awesome! This did it. Question, why do I need to import flash events?
Ole Media
You always need to import any class which is not defined in the same package as your code. This will allow the compiler to unambiguously locate the definition of the class. If this were not required, you would run into trouble if two classes in different packages had the same name, not to mention that it would burden the compiler with having to search every single possible location for each class definition it didn't immediately find in your package.
Michael Aaron Safyan