outburst.jloop.com

3/8/2005

Dynamic assets with Shared Libraries

jay jay @ 2:46 pm — Filed under:

I’ve had a love/hate relationship with Shared Libraries from the time I first started trying to use them when developing www.tonyrobbins.com. I think the concept is great - with the ability to share simple graphic assets, even code snippets or classes across multiple swf files using a central library file. The main problem I have yet to find a great answer for is the loading process. There is no way to truly monitor the progress of loading shared libraries without a workaround.

This is particularly difficult when working with a shared library that contains entirely dynamic assets that you intend to add to your app at runtime using attachMovie or something like that. The movie you are bringing a shared library into must actually have an asset from that library on the stage somewhere to trigger the loading of it. Here’s the workaround that works for me.

1. Create a blank movie clip in your shared library and call it “assetLoader” or something like that.
2. Export it along with all the other library assets you are using.
3. On frame 1 of your destination movie, you can load your shared library in on _level2 and monitor its load progress that way.
4. On frame 2, you can unload _level2 and place a copy of your blank shared asset “assetLoader” on the stage… this will force the movie to load the library swf in correctly. But since you’ve already loaded the file into cache in step3 above, this process doesn’t need to be monitored and should be instantaneous.
5. On frame 3, initialize your app and you are off and running.

If anyone out there has a better solution than this, I’d love to hear it.

Comments are closed.

Powered by WordPress