Since my unbridled enthusiasm for swcs a few posts ago, I’ve been sharply brought down to earth about just how unreliable they are. I’ve come across a couple of different problems that just defy all logic. While I still think they are by far the best solution for projects where you want to have your assets compiled into the swf, there are some things that will make you want to stop doing Flash development and go take up pig farming instead.
1) Sometimes your swc will just fail. This seems to be in some way related to the number of assets in the fla, but not neccessarily. You’ll know you’ve got this one when the previously fine references to the swc classes suddenly break, as though it can’t find them. Richtextformat has got a full explanation of the “solution” to this problem over on his blog.
2) Your swf can’t find the document class anymore. I have an fla that held all the assets for my Flex based project. I’m compiling this to a swc and then using that as a library. All fine. However, the designer doesn’t have Flex, so he wants to compile directly from the Flash IDE. So, I set up the document class for him. However, when the fla is compiled, nothing appears. No errors, no traces from either the document class or the timeline. Nada. The problem was that I had left Export SWC on in the publish preferences. Unticking Export SWC did nothing however, it required the swc to be deleted. Then, it worked. All I can assume is that Export SWC was generating a duff swc, which in turn was breaking the swf.
The solution workaround hack I’m using is to have 2 flas. One is set up for compilation from the Flash IDE, the other a blank, unsaved fla (as per Mr TextFormat’s instructions) to generate my swc. This is a pain in the arse, let’s be honest. Every time the fla is updated, I have to refresh the swc fla assets and recompile. I guess I could write some kind of jsfl script to do it for me, but I’ve wasted enough time on this already
Anyway. It seems that the Export SWC command in CS3 is really broken. I’m going to try on CS4 and see if it’s been fixed. Fingers, toes, tentacles and any other prehensile appendages crossed.
[Update - It seems like this issue only occurs if you are building the swf/swc into the same directory as the fla. I've tried it with a couple of builds to outside the directory, and it seems to be ok - there might also be an issue if the fla is inside the Flex directory structure but I haven't confirmed this. More testing is needed...]