I’ve been using Shared Libraries for years, and only found out yesterday that they lazy load. Meaning, they load on the fly. I’ve made preloaders in the past for SharedLibraries, but wasn’t realizing that my “usage” of an asset was the thing actually triggering the load. It worked so I just moved on with life.
A Shared Library is a SWF that has symbols in it specifically made to be shared in multiple FLA’s. That way if you have an app that has multiple SWF’s, they can all share the same asset. This works great for large, internal videos, fonts, and sounds.
We had to do it because we have a design that uses 5 fonts. At an average of 12k to 20k per font, you can see the need to ensure that all 32 or so SWF’s all share the same font. We bring in the font symbols as imported for shared libraries, and viola. The path that they import from, the framework.swf, is problematic since it’s hard coded into the SWF. You can change it by right clicking on the symbol in the library and selecting “Linkage…”, but that’s a pain in the ass if you want to test locally vs. deployed to site.
No url is hard coded anywhere since we are using an Akamai load-balancer so these are the only exception per-se. Since they are relative, they still respect the load balancer. We’ve used JSFL to make our testing vs. deploy scenario transparent; the scripts update the Shared Font paths based on whether you are testing or deploying.
Anyway, in testing, my co-worker Tony showed me how to see what the SWF was loading. I don’t have ServiceCapture on my work PC up here, so he had me install TamperData . It’s a hot Firefox plugin that shows HTTP traffic. You can see the SWF make a call for the Shared SWF when the asset is used; it’s pretty neat! Great extension to have when you don’t have ServiceCapture. Don’t know if it can see AMF though, only HTTP stuff I think.
Most of the Shared Library stuff is different in Flash Player 9 and Flex 2 . I believe Roger mentioned awhile ago about how SimpleApplication uses like the Frame metadata to put shared font symbols on frame 3 or something… :: shrugs ::. Anyway, getClassByName will allow access to other SWF’s libraries now so the Jenga world is a lot easier, but although the docs say you can’t do it in ActionScript only projects, I haven’t tested personally. For those of us still doing Flash 8 and below, it works good.