Where have my swc graphic assets gone?
There is a fantastic technique for getting graphics drawn in Flash into Flex by means of classes compiled into a swc. It’s a really nice little method and if you wanna learn about it Ultraviolet Design have a great post about it here. I’m pointing you towards their post as this post is not going to be about that. Instead it’s going to be about what happens when that technique - which usually works fine - goes unexpectedly and bafflingly wrong.
Last week, having picked up a half-finished project from a new client that utilised said technique, I made changes to some of the graphics in the .fla and recompiled the swc. At which point, over in FlexBuilder, the ‘Problems’ dialog flashed up 99 seperate errors. 33 each of the following three:
1172: Definition com.somewebsite.graphics:SomeGraphicsClass could not be found.
1180: Call to a possibly undefined method SomeGraphicsClass.
All 33 library assets that had been assigned classes were gone? How? Where? Why?
The answer: I don’t know, but I do know how I fixed it. The problem was in the .fla file. If the file had been saved it was incapable of exporting a valid swc. It looks like a bug in Flash or possibly with the actual .fla itself. But there is a fix and this is it:
- Open a new .fla file
- DON’T SAVE IT, NEVER SAVE IT
- Copy the entire library contents from the saved ‘corrupt’ .fla to the refresh, unsaved one
- In the ‘Publish Settings’ ensure that ‘Export SWC’ is clicked and that the swf is exporting to the right location with the right name
- Compile the swf
When I did this all 99 of my errors disappeared.
I think to call this a ’solution’ is euphemistic but it worked for me and might well work for you. I guess the only real solution is for Adobe to bugfix their own product. Whilst we wait for that to happen though, we can use this workaround.
Tags: ActionScript3, AS3, error, FlashBrighton, swc
November 12th, 2008 at 8:10 pm
Hi Richard, I wrote the article for Ultraviolet Design. Appreciate the link back. Coincidentally I also wrote a post about this problem however I attributed it to using multiple swcs in one AS project in Flex Builder. I have more recently realised (and had this confirmed by your post) that it is just a bug in Flash, which we are at the mercy of. Very frustrating but what can you do.
November 18th, 2008 at 1:44 pm
[...] 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. [...]