Flash MX 2004 Components only support 1 Shared Library Tier

I don’t have time to see if other, custom made SWC’s suffer the same fate, but the gist of it is, if you create a component and use say the “Button” component in your component. You then export your Button component for runtime sharing, and point the URL to the SWF name your compiling too, and then copy the main component to another SWF, he’ll work. Your Button in there will be importing from the Shared SWF.

…however, in publishing to both 6.0.65.0 and 7, while running in 7, once you add another tier, it doesn’t work. It has something to do with execution order, because if I manually drop the Button component on frame 1, and then the shared component who uses him on frame 2, the component will then work. This is not, however, how things are supposed to work. Because I can’t see behind the scenes of what initclip is doing, I’m not sure how to fix, but your supposed to just drop the component inside the component that needs it on a layer on frame 2. This isn’t working, however, so more study is warranted.

Oddly, I do not have this problem when utilizing the Central components in this way.

15 Replies to “Flash MX 2004 Components only support 1 Shared Library Tier”

  1. Ok, here’s my theory.

    At compile time, Flash uses external class files to determine #initclip order. However, since SWC’s are already compiled, Flash can’t since it can’t recompile them.

    …not sure why it works in one tier, though…

  2. This is just a and I don’t know much about model views and what not, but maybe they have a standard way (or not) of setting #initclip for components.

    So components like UILoader always have an #initclip of 0 and the MediaDisplay would be 1.

    They need a standard of setting #initclip and documenting it. If they wanted the new EULA to encourage development where we can extend an swc by embedding it in our own component, then they need to provide technotes on it. Unfortunately Macromedia seems to have abandoned the technote in favor of packaged documentation and complete articles.

    UI components should probably be #initclip 0 and everything else should start at 10 or something to give devs room to develop.

    Either that or my understanding of #initclip is misguided.

  3. The problem is, you don’t use #initclip in ActionScript 2.0, so… Flash just “knows” via what classes you import or use to set up init order. That’s why it’s confusing on who’s initing when and where…

  4. There has to be some logic behind it. Someone at Macromedia must understand it. It would be difficult for someone else to figure it out using a trial and error troubleshooting technique (not my favorite).

    Could it be relative to directory level and/or alphabetical directory/file naming?

  5. Would it not depend on (hehe) dependencies? Could it be looking at what class is dependent on what and init the furthest down in the chain first? Just a thought. Then your theory, Jesse, on SWC’s might be correct.

  6. Well, Image Chooser uses Button and Image Loader. However, FormHolder uses ImageChooser… but ImageChooser doesn’t work…unless I manually place Button on the timeline + ImageLoader first. It’s so lame. Because I can’t use #iniclip, I’ve got to have faith in Flash implementing the correct sequence since that’s supposedly how #init order is determined in AS2.

    …I’m thinking I’m going to just export the low level classes into SWC’s, and then use them in a master app. The only problem with that is I lose Unit Testing ability; the very reason I use Shared Libraries in the first place. Now, if I wish to test a component again, I have to open the original FLA, export the SWC after the change, and reboot Flash, open the original FLA, and replace the SWC in the library.

    …lame.

  7. Why do you need to reboot Flash? Is it because you want to refresh the Components Panel? Or is there something about the Library itself not updating the SWC properly?

  8. If I export an SWC into my Flash’s Components folder, whether First Run, or the Local Settings directory under Documents and Settings, I have to reboot Flash to get the new SWC to be updated. I’ve tried closing and opening the Components Panel, but maybe I did it wrong?

    I don’t know about other developers, but my SWC’s are never perfect the first time to deploy, and if I want to make changes later, this is the only way I know how to update the SWC in the components panel.

    …this of course assumes there isn’t a better way to use SWC’s?

  9. Actually, click the little icon in the Components Panel where Help and other commands are located. Voila! Refresh. This way you don’t have to shutdown Flash everytime.

    In fact, I made a little app in SWF Studio that sits in my system tray. When I update a component and export to SWC, I right-click on the app, select the file to copy and the location to copy it to, and click copy. Then anytime after that I just click copy. Then refresh the Components Panel. That makes updates a snap in MX04.

  10. d00d, you saw what happened when Chafic posted his Flashtools. I suggest you do the same for yours… hell, charge for it if you want; peeps would buy.

    BTW, thanks a ton, that is a major timesaver!!!

  11. Reload doesn’t work, at least not for me. Every time I make a change to the actionscript I have to export the SWC, shutdown Flash, and re-open Flash and drop the updated component into the movie again.

    I’ve found this works only *some* of the time. I’ve run into a problem now where Flash refuses to update my component, no matter what I do. I even tried deleting both instances of the SWC (username\docs and settings\etc and \flash_root\etc), re-exporting the SWC and it’s using an old version of it still!!!

    It must keep a hidden cached copy or something. Is this some cruel joke, my own stupidity, or is Flash just plain retarded?

  12. After much testing and brute trial and error, I think I’m zeroing in on the bug in the loading order of V2 components. In my application it was manifesting as broken RectBorder objects in all the V2 components that I was instancing from my component (they wouldn’t draw or if they did, they wouldn’t resize). I was able to fix this by simply adding ‘import mx.core.View;’ to the TOP of my custom class. Oddly, ONLY this statement would help the situation – importing the classes that View imports did NOT work. My guess is that there’s something up with the DepthManager, but it’s really hard to tell with all the interdepencies between the V2 classes. What a mess! I hope this fix works for you…

  13. In Flash 8:
    1. you re-create the SWC
    2. reload the components panel
    3. drag the component from the components panel into the library of the movie that uses the component
    4. tell it to replace the existing item
    5. Control > Delete ASO files and Test Movie

Comments are closed.