A new version of FlashDevelop has been released and among the updates are some tweaks to the autocomplete feature. It’s worth pointing out that this 3.0.0 version of FlashDevelop is starting to include some integration with the Flex debugger (currently only trace statements are supported), something which I feel will really make the tool a viable alternative to Flex Builder. Java 1.6 is required for Actionscript 3 development so grab that as well if you want to test out all the features of the latest build.

FlashDevelop 3.0.0 Beta 4

Java 1.6 (Java 6)

If you try out FlashDevelop and like using it, don’t forget to support the project by donating!

Recently I wanted to find out how to compile SWC libraries which could be used in Flash CS3 since I knew it was possible to go the other way using the Flex Component Kit for Flash CS3. As of Flex 2.01, support was added so that Flash and Flex authored SWC’s were compatible (previously I believe the SWC format differed between them). The focus of the update however was on getting Flash authored components into Flex and only in passing was the reversed case mentioned as being supported.

I figured the best starting point would be a normal Flex library project in Flex Builder. After adding a class and compiling a SWC, I dropped it into the Components folder under Flash CS3 to see if it would show up. This folder is usually found here:

C:\Documents and Settings\{username}\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\Components\

This is the folder where MXP’s typically put component SWC’s so that they show up in the Components panel in the Flash IDE. Anyway, after dropping the SWC in and refreshing the Components palette I didn’t see anything new. So I was back to drawing board.

After re-reading the quick start guide regarding the deployment of custom Flex components I thought I’d try the recommendation given regarding the creation of a manifest.xml file. I had never done this before because it’s mentioned as an “optional” step and we’ve never done this for any of our libraries at work. Usually if my library project compiles a SWC, I’m happy. From the article:

Manifest files map a component namespace to class names. They define the package names that the components used before being compiled into a SWC file. They are not required when compiling SWC files, but they can help keep your source files organized.

Well it turns out that this was the missing piece. I created a manifest.xml file which listed my component and then updated the compiler settings to point at this file.

Flex compiler settings

manifest.xml

Notice the key part where a namespace is specified as well as the path to the manifest.

After dropping the newly built SWC into Flash’s Components folder, the new component showed up and I was able to drop it into my library!

This brings me to the point that I imagine one may be wondering, why would you even want to do this? Well in my case I was working on creating a MovieClip based component that was aware of some interfaces we use in our framework. This is similar in spirit to the UIMovieClip class that is included with the Flex Component Kit. I could probably create this component using Flash, then point the FLA to the library where our interfaces might live, but I wanted to see if I could do it from within Flex Builder. I think there are a few other reasons someone might want to do this:

  • developer prefers to work in Flex Builder (better code completion, familiar environment, etc
  • SWC creation could be part of an automated build process via ANT
  • easily create a SWC based on other Flex libraries

I think the last point might not apply because I’m pretty sure if you put Flex authored (2.01) SWC’s in the classpath for an FLA, it will be able to see them. I still think it’s nicer to use Flex Builder for this though.

There’s one caveat I should point out. I’ve only been able to create base classes or utility classes so far using this method. If you want to create a view component, let’s say a new video player component, there’s a trick that dates back a few versions of Flash where one has to put something in the first frame of the component MovieClip before exporting it as a SWC from within Flash. This still seems to be the case and if you try to create a component using the method above, add the SWC to the Components folder, then drag it onto the stage, nothing will show up. You will have added the component to the FLA’s library though and this is useful for getting classes into the FLA. Maybe there’s a way around this and I just haven’t explored enough.

Another thing to note. I’ve been told (courtesy of Peter Watson from Adobe) that if you’re using Flex 3, then you need to add the following compiler option in order to create a SWC that works with this method I’ve outlined above.

compute-digest=false

Apparently this prevents the compiler from creating a newer format SWC which is compatible with the new RSL caching mechanism. I had noticed that the SWC’s I created in Flex Builder 3 weren’t working in Flash CS3, so this should help fix that (haven’t tried it yet).

I know some more screenshots or a video would be useful in explaining this so feel free post comments and ask questions. I wanted to post something as soon as I could because I’ve seen this topic brought up a few times in the comments on other blogs. This use case of creating SWC’s which are used in Flash doesn’t seem to be highlighted anywhere in the documentation and I think it could be useful for certain projects.