Posted on Wednesday 6 September 2006
I’ve been working with Flash for so long now that I’m really wondering why I’ve yet to encounter this bug before. Basically I was attempting to use another movie as a library for the current project I’m working on. Simply enough, I first loaded the library movie using MovieClipLoader (although loadMovie gives the same results), and then attempted to use attachMovie in the base movie with linkage ids from the loaded library to drop in the assets where needed. Turns out you can’t do that. Apparently the linkage ids are unavaible outside of the loaded movie. WTF? I guess you could call it a name clashing prevention feature, but I won’t. There’s a nice write-up about it here.
I have a feeling there is an obscure workaround for this. For example, I am guessing that Aral’s swf optimizer works by extracting components from several swfs and putting them in another swf, then automagically loading the library swf at runtime. I also believe that it’s possible to then use attachMovie to drop components on stage (or equivalently using createClassObject which is a wrapper for attachMovie). But this would contradict the existence of that loadMovie/attachMovie bug. I’d use SharedAssets, but I’d like to keep my sanity. Any idea what this mysterious magical workaround is?
Update: Calling it a name-clashing prevention feature would be pushing it, indeed. I just tried the following: parent movie, make a movie clip with a circle in it with linkage id “myasset”, library movie, make a clip with a rectangle in it with linkage id “myasset” and AS2 DummyClass. Make class DummyClass with onLoad function trace(”hello world”). Load library movie in parent movie and attachMovie myasset. Result: a circle on stage and hello world in the output window. Flash, I think it’s time we start seeing other people…
Update 2: Since I only need pictures, I can attachMovie inside the library, then copyPixels… You see where this is going. I love workarounds.


