1

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 depended 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?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
deadbeef
  • 53
  • 3

1 Answers1

0

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.

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
  • I'm looking into using RSLs. The problem I'm running into now is that the class definition is still compiled into my main container swf when publishing from Flash CS5, even after marking the libraries as external or RSL.. I can use command line compilers to achieve the results that I'm after, but I need to figure out a way to support this from within the Flash IDE as well.. Any ideas? – deadbeef Jul 18 '11 at 20:09
  • Is this Flash Pro or Flash Builder? Your SWF should compile only assembly that needs to be linked. Are you sure there's no reference to that class definition in your main container? – Jason Sturges Jul 18 '11 at 22:55
  • Using Flash Pro. I've set a reference to an external swc and have set it as "external" which, according to Adobe docs, should exclude any class definitions (even if referenced in the container) from the container. Problem is, it's not working - it's *really* starting to seem like a Flash Pro bug as it works fine from command line. – deadbeef Jul 19 '11 at 22:08
  • Clearly you've hosted any external references as well, of course? (external linkage deployed to your environment). Everything has been preloaded? Is there an exception generated at runtime? Probably 'Class ... not found'. [This post](http://www.wannaknowflex.com/2010/05/flex-linkage-difference-between-rsl-and-external/) has been mentioned here regarding linkage. – Jason Sturges Jul 20 '11 at 00:44