开发者

AS3 alternatives to *_exclude.xml files, loading class definitions dynamically

I've been banging my head against a wall for this for almost a couple days now and hoping that someone can point me in the right direction.

Working in a very large Flash application, previously in AS2/CS3 I would have a setup like the following:

root.swf
-- modules
---- code_a.swf
---- code_b.swf
-- views
---- view_a.swf
---- view_b.swf

Using _exclude.xml files, I could exclude the classes defined in code_a and code_b from the ouptut .swf of view_a and view_b. root.swf would be responsible for loading the code modules before view_a or view_b, ensuring that class definitions that view_a and view_b de开发者_如何学运维pended on existed.

The Problem

We've recently migrated to using Actionscript 3/CS5. *_exclude.xml files no longer exist. To get the same functionality as above, I've tried the following:

My setup now looks something like:

root.swf
-- modules
---- class_a.as
---- class_b.as
-- views
---- view_a.swf
---- view_b.swf

Use mxmlc to compile root.swf, view_a.swf and view_b.swf, passing it -externs option to specify classes that will be loaded externally (the two classes in modules). This ensures that the class is excluded from the compiled swf.

Use compc to compile class_a.as and class_b.as into classes.swf, using -directory=true to access library.swf for external loading.

However, when I try running one of the two view files which depend on classes.swf, I get runtime errors telling me that a class definition is not present.

Current Workaround

I've devised a workaround which I'm currently not happy with as it's backwards to the modular approach that I was previously using:

Rather than loading the code modules, I statically link all class definitions required by child movies into root.swf. When building root.swf, I use the -link-report option of mxmlc to provide a list of included classes. When building child swfs, I can the use -load-externs to ensure that class definitions that already exist will not be included in the compile output.

Is there a way that anyone is aware of to replicate the AS2/_exclude.xml solution that I had using AS3/CS5?


I'd recommend compiling shared libraries to SWCs.

There are other options such as RSLs:

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf674ba-7fff.html#WS2db454920e96a9e51e63e3d11c0bf69084-7f1e

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜