Wednesday, October 24, 2007

Flash CS3 and SWCs

A co-worker called me up recently to ask me how to use a SWC with Flash CS3... A SWC is a collection of compiled ActionScript classes, similar to a DLL or JAR. They are very easy to use with Flex Builder and the Flex compilers. In this case, there was a SWC that I had created that my co-worker wanted to use in his Flash project. I knew that this was a pain. 

Flash CS3 thinks that SWCs are for UI components. You can create a SWC with a manifest.xml (in Flex Builder), drop it into your components directory, and use it. That's great for UI components, but not for class libraries.

On an older project, the developers using my library just linked to the source code directly to compile. I told the new developer to do that, but he quickly pointed out that the new version of my library used Adobe's corelib library... which is also a SWC. 

So the first thing I did was take the source of corelib and zip it together with the source code of my library to give to the developer. Now he could work while I solved this SWC problem. I saw a post on the corelib group site, but it did not quite solve my problem. So I emailed one of the corelib developers from Adobe.

He thought I should be able to add any SWC to the CS3 project's classpath (file->publish settings -> flash.) That did not work. I was able to compile against classes in the SWC, but got runtime errors equivalent to a Java NoClassDefError. 

About the same time, I was reading some documentation on PureMVC, an AS framework that looks promising to me. I noticed that it was supposed to be able to work with Flash CS3 and it was distributed as a SWC. I read the install directions for CS3 ... they indicated that you needed to use the source code, not the SWC.

So now I'm thinking that there may not be a solution to this problem. Maybe this is a bug in Flash CS3?

6 comments:

  1. Did you ever solve this? We're having the same issue on our end.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Unfortunately no. However, it does work as you would expect in the betas of Flash CS4 (at least up to beta 3, I haven't tried beta 4.) You just add the SWC to the classpath under Publish Settings / Flash. So it looks like Adobe fixed this is CS4, but not in CS3.

    ReplyDelete
  4. ah what a drag... do you happen to have any clue when cs4 gets released?

    ReplyDelete
  5. This is one of the Important and memorable post.This is one of the knowledgeable post.
    Android app developers

    ReplyDelete
  6. How to import swc in CS6

    Zopy games

    ReplyDelete