Help setting URLs for import/export for runtime shared library

Summary: I don’t quite understand how the import/export URLs for symbols in a runtime library work. I can’t figure out how I can set them so that the runtime library will be properly loaded and accessible for other swfs to import from, if I want it to work both in a local environment (on my harddrive), and from a remote environment (on a web page).

Relative URLs seem to work great for the hard-drive case, but fail for the web page. Is there a magic way to set the relative URL to work from the web too?

And/or, is there some way of manually loading up the RSL at runtime and making the importing swfs import from that loaded copy, rather than having Flash doing it behind the scenes based on the import URL set in the symbol?

Following is a longish description of what I’m trying to do, and why…

I’m trying to figure out if we can use RSLs to contain common UI controls for our next project. I’m running into an organizational issue that I can’t quite figure out - how to get the RSLs to work in both a local development/debugging environment, and on a production web environment, with the same exporting/importing URLs.

Here’s what my setup would look like. Say I have a main application main.swf, an RSL lib.swf, and a UI module dialog.swf.

Main.swf loads or embeds dialog.swf. lib.swf exports some symbols that dialog.swf imports.

On a local development environment, these swfs are found in folders like so:

C:/proj/main.swf
C:/proj/assets/dialog.swf
C:/proj/assets/lib/lib.swf

When published to the web, the folder structure is similar:

//webserver/root/main.swf
//webserver/root/assets/dialog.swf
//webserver/root/assets/lib/lib.swf

http://myapp.com/ maps to //webserver/root. So, http://myapp.com/main.swf will load the app.

Here is the problem. If I set the export/import url for symbols in lib.swf to “assets/lib/lib.swf” (relative to the location of main.swf), the runtime library gets loaded fine in the local environment. The symbols are imported by dialog.swf. But in the web environment, it does not load - the player just shows the “…” graphic indicating it is trying to load/import, and failing.

Alternatively, I can use “http:/myapp.com/assets/lib/lib.swf” as the export/import url. Now, it will work in the web environment. However, in the local environment, dialog.swf will load symbols from the lib.swf that is out on the web, not the one that is local. But I need it to load from the local version, so that designers can muck about with the assets and see the results locally before publishing to the web.

Is there some alternative way to set up the swf’s, or way to set the URLs, or some other hoop I can jump through that will make the RSL import work in either environment without having to manually change URLs all the time?

(Details: I am using Flash Builder 4, CS 5, Action Script 3, Flash Player 10… No Flex! My example omits some details from my actual setup, such as the fact that we are using a preloader to load the main application, and a php script on the web page to start the preloader.)