PDA

View Full Version : Importing custom AS classes?


ryeguy
10-05-2008, 10:43 PM
This is such a simple topic, and even using the example in the Flex help file, I still can't seem to get it to work.

I have this class in test.as:

package mypackage
{
public class Alert
{
public static function RecordEvent(event:String):void
{
mx.controls.Alert.show(event);
}
}
}


In my MXML file I have this:
<mx:Script>
<![CDATA[
import mypackage.Alert;
]]>
</mx:Script>

However, on the line of the import, I get this error:
1172: Definition mypackage:Alert could not be found.

What's the problem here? It's so simple and straightforward that it's killing me. The weird thing is is when I type "import" in the Flex IDE it pops up mypackage as a choice in the auto completion, so obviously it knows it exists.

drkstr
10-05-2008, 10:55 PM
The auto complete is based on the contents of the file. It doesn't know your file is in the wrong location with the wrong file name.

Your class should should be in a file called Alert.as and located in a directory called 'mypackage'.


Best Regards,
~Aaron