Max
Max

Reputation: 8045

how to force compiler compile all classes in my project?

im using Adobe® Flash® Builder™ 4.6,the problem also exist in previous versions.

for some reason ,i am using

cls = applicationDomain.getDefinition(name) as Class;

to get the object's constructor and then create the instance of my modules class.thus make compile ignore my module classes ,because they are not related from my main class.how to force else classes also compiled into my swf or swc file? i didn't find where i can adjust my compile option.

by now i use this way to solve my problem,at the very beginning of the program entry.

if(1+1==3){
    //never be run but do make classes merge into swf files.
    new MyModule();
}

i have hundreds of modules like this one,i do hope i can find a way to solve this problem permanently

Upvotes: 1

Views: 1568

Answers (4)

Raja Jaganathan
Raja Jaganathan

Reputation: 36107

You can try with this

package
{
public class IncludeClasses
{
    import com.abc.db.Database;Database;
    import com.abc.logs.RemoteLogTarget; RemoteLogTarget;
    import com.abc.logs.LocalLogTarget; LocalLogTarget;
    import com.abc.exception.GlobalExceptionHandler; GlobalExceptionHandler;
    import com.abc.utils.NetConnectionMonitor;NetConnectionMonitor;
}
}

Upvotes: 2

haysclark
haysclark

Reputation: 1080

You can also do this by setting your compiler flag. About the application compiler options

See: include-libraries library [...]

Include only classes that are inheritance dependencies of classes that are included with the include-classes compiler option.

The default value is false.

This is an advanced option. You might use this compiler option if you are creating a custom RSL and want to externalize as many classes as possible. For example:

compc -include-classes mx.collections.ListCollectionView 
-include-inheritance-dependencies-only=true 
-source-path . -output lcv2 -directory

Upvotes: 0

Vesper
Vesper

Reputation: 18747

You need at least one strict reference to your class to appear within the project. I use a static variable of type Array to stuff all of the classes I need, and never really reference that array, if I can.

private static var dummy:Array=[OneClass, AnotherClass, Class01, Etc];

Upvotes: 1

The_asMan
The_asMan

Reputation: 6402

You need to use the class to get it to compile in the swf.
Not the best method but

private var someVar:someClass;


Using the "new" keyword will cause the run-time to allocate memory for the object so you don't want to use that.


This whole loading modules and compiling classes has a code smell to it.
You would be better off having your classes in the modules implement an interface.

Upvotes: 2

Related Questions