Archive for the 'actionscript' Category

Flash IDE loves Flex 3 SDK with SWC compiled components

Tuesday, August 18th, 2009

Our flash development team have just setup a fantastic workflow for flash/flex/actionscript projects which I thought I would share.

Flash Designers use Flash CS4 IDE
The flash designers work with Flash CS3/CS4 in a fairly typical way, publishing from the Flash IDE. The IDE makes it very convenient for working with graphical assets, something which is very tedious in a code-focussed environment.
Flash Developers use FlashDevelop and Flex3SDK
The flash developers use FlashDevelop exclusively, and they compile their projects using Adobe Flex3SDK. They only publish SWFs for testing purposes, their real goal is to build the more complicated and powerful components that form the building blocks of the application. (These are code-based, non-visual components - sometimes called base classes or utility classes).

The trick is how all these users can work together.

Create SWC components from AS3 Classes for two way integration
We can export these non-visual components as swc files that can be used in two ways a) Designers can load the swc file into the CS3/CS4 library. From there you can use it just like a normal class, only you don’t need any of the code on hand, and more importantly, you don’t need to compile the code each time. This results in lightning fast compile times (a few seconds) and prevents your designers from screwing up your code. In truth, our designers are generally using flash develop a lot of the time anyway, due to nice things like code completion, a code-editing interface that wasn’t designed by an adobe intern, etc.

Furthermore, it’s not only the developers who can build and distribute their work as swc files - the designers can also export their visual, movieclip based classes in swc format. (Library panel >> Right click on library item >> Export to SWC). This is actually the key to closing the loop - if you want to compile your project from Flex3SDK, you naturally need all your visual components prepared in this way. In truth, we have not found that any of our projects have warranted this step to date - you seem to end up with a very unworkable library system where everything is so darn hard to edit. Furthermore, there is the added bonus that it keeps your developers honest, since they are forced to build self-contained, easily testable units.

Compiling SWC Components using compc.exe
We use the Flex command line tool (compc.exe) for compiling standard code-based classes into SWC. i.e. Classes that are code based and do not extend from Sprite, Movieclip etc. In this case we’re packaging up all the classes for Papervision3D into an swc named pv3d.swc.

Gotcha: Note that due to adobe/flex specialness, we needed to create a separate dummy class called PV3D outside the “include sources” location to avoid strange compiler errors lik “The definition is in circular inheritance” and “Could not find source for class Papervision3D in namespace…” and other fascinating tidbits. It is this dummy class that we tell the compiler is the main class for the component, even thought what we really want is all the other classes packaged up inside.

Compc command line arguments
c:\Flex3SDK\bin\compc -source-path c:\wwwroot\myproject\ -output PV3D.swc -include-sources c:\wwwroot\myproject\org\papervision3d -strict=false -compute-digest=false -namespace http://papervision3d.org c:\wwwroot\myproject\manifest.xml -include-namespaces http://papervision3d.org

Contents of the manifest xml file is as follows:

And Voila! You’ve got an swc file which contains all that papervision goodness. You have two options for using this.

  • Flash IDE folk: Copy the swc into your flash components folder, close and open flash to refresh the components panel, then drag your component on the stage or into your library and hey presto.
  • FlashDevelop/Flex folk: Put the swc somewhere nice like inside the /lib folder (it doesn’t actually matter where you put it). From the XYZ panel in FlashDevelop, right click on it and “add to library” to ensure that all it’s classes are available by bundling it up into your output swf. Bonus for FlashDevelop users is the ability to browse all the classes included inside the swc file.

I hope that helps a few of you out there trying to find their way in adobe’s increasingly confusing flash/flex journey.

Lastly, a few helpful references here and there:

SETTING UP FLASH DEVELOPMENT ENVIRONMENT WITH FLASHDEVELOP / FLEX SDK

  1. Download latest flash develop (3.0.2) - requires java 1.6. http://www.flashdevelop.org/community/viewforum.php?f=11
  2. Download latest Open Source Flex3SDK (v3.3) and extract into c:\Flex3SDK http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk
  3. Configure Flash Develop to use Flex3SDK. Tools => Program Settings => AS3Context, set Flex SDK location to c:\Flex3SDK. Ensure you right click on any swc files that you want to include and choose “Add to Library”

Special thanks to Tim Walling for getting us started: http://www.timwalling.com/2007/10/22/compiling-flash-cs3-compatible-swcs-with-flex/

Official Flex documentation here for compc.exe (beware, it’s typically clunky) http://livedocs.adobe.com/flex/3/build_deploy_flex3.pdf

Apparently there’s an Export SWC plugin for Flash develop floating around, but I think that once you’ve got the hang of it, it’s probably easier to just use the command line version, outlined above. http://www.flashdevelop.org/community/viewtopic.php?t=2987&start=0

FORTUNE MAGAZINE LABELS SUNGEVITY “THE DELL OF SOLAR ENERGY”

Wednesday, June 4th, 2008

Console Logging for Flash (i.e. Tracing in a browser)

Monday, May 26th, 2008

Thanks Flash Gurus

Thursday, May 1st, 2008

JSON for Actionscript 2 update to fix ordering bug of object properties

Thursday, May 1st, 2008

HOME | CONTACT Copyright © 2010 Extro Interactive