views:

225

answers:

2

Hi all,

I'm working on a large application that is broken up into many independent swfs. There is a master swf that loads a navigation shell and the foundational logic, and a module loading system that loads child swfs into the main display area. This is all working smoothly, and now I'm onto building the modules, and I'm starting to feel like my methods aren't as efficient as they should be.

The module swfs (and corresponding flas) are located in a "modules" subdirectory of the main project's src folder. These modules share a large number of classes. In fact, most them define no new classes that are specific to just that module. The shared classes have a complicated structure of inheritance and interface usage, and are located in a view/structure subdirectory of the main src folder.

Currently, in order to use the shared classes from view/structure in my module swfs, I add the main project's src folder to the source path in each of the module flas. Besides being a bit tedious to do every time, it 1.) Redundantly compiles the shared classes into each module increasing file sizes across the board, 2.) Requires addition of new source paths to the modules for every developer who wants to work on/test the application because they are absolute values and different on every os's file system, and 3.) Doesn't allow modules to be built independently without access to the main project src folder

I did a bit of research on RSLs in flash, but I couldn't quite see how I would fit them into this scheme.

Any ideas? Many thanks for reading.

-Dane

A: 

I am not 100% sure I understand your question. But you can modify the classpaths that flash uses when looking for .as files. Go to

Edit >> Prefences >> ActionScript (under Category) Click in ActionScript 3.0 Settings Add relative paths to your Source path.

So, if you are working on an fla in src/modules and you want to use classes from src/view/structure then simply add ../ to your source path. That will tell the Flash compiler that instead of looking from the current directory only, take a look up one level to see if you can find a class there.

If I have misunderstood your question, please clarify.

sberry2A
Thanks for your suggestion... short of using RSLs as Theo described, this would also improve things and is good to know.
Dane
+1  A: 

In this case I highly recommend to use runtime shared libraries. I've never done it from Flash IDE directly since I always compile via Flex, however I guess it should be almost the same logic from Flash IDE, but you may have to tweak the following solution a little bit though as I'm writing it from the top of my mind without ever having tested it ...

Include all the main classes to be shared within the main shell by referencing them somehow in its code (the compiler includes classes the lazy way and the non referenced classes will not get included and exported).

To ensure the consistency of the shared classes, publish an SWC of the used classes (tick 'Export SWC' in publish settings). You can always double check the SWC's content simply by unzipping it.

Within your loaded modules remove the class paths from the "Source Path" / "Library Path". Instead, add the SWC freshly created to the "External Library Path" listing. When you now export your modules the classes found in the SWC will not get included in the SWF's.

Note : You may probably get runtime errors ("definition not found ...") when you export/run the modules externally from the main SWF. This makes sense since the definitions you stripped out are meant to come from the main SWF.

Theo.T
+1.. It seems to me like the scenario Dane describes is exactly the situation where RSLs are valuable.
Ipsquiggle
Thanks, this sounds like the answer I'm looking for.
Dane