Forcing classes to compile in AS3
Friday, May 9th, 2008when you use the "import package.Class; " or "import package.*; " in AS3 the class(s) is not forced to be imported. A class is only imported if you use it somewhere in your code.
The simplest way is to just type its name:
Actionscript:
import sprites.Ball public function init(){ Ball; // Or for many at once (Ball,Dirt,Kid,People); }
Just simply typing the class type somwhere in your application will force it to compile in. Why is this of any use you may ask?
We use it for level building in games, where you have a generic component as a placeholder used in flash to lay out content/levels. Your Ball class for instance, might then simply build itself using externally loaded assets, and attach itself to the stage. It may not need to be referenced anywhere in the application, but is still compiled in.