Friday, July 11, 2008

SWCs and FlashDevelop

I'm thinking my Bits of Blender episodes are really cutting into my blogging time! But I thought I'd put a note out on my latest development approach in FlashDevelop for Flash/ActionScript 3 projects.

Previously, I'd set the main class as the Document class. Then I would set the parent class of Symbols to a corresponding ActionScript 3 class. I'd turn off the automatic declaration of variables so that it would force me to declare them in the class. This was nice because I would have a reminder at the top of the class that there were named instances in the symbol. I'd also add a "//MC" after the declaration as another reminder why I had those members set to "public" (I'd also set "//MC" as one of the tasks so I could quickly find all the named instances on the stage).

But for a recent project, I decided to go with compiling in FlashDevelop instead of Flash. When I'd used FlashDevelop for some Flex work last year, I was always impress with how quickly it compiled. Flash seems to take much longer. I think it may be because FlashDevelop uses the Flex compiler which is doing incremental compiles and Flash is always compiling everything (I'm guessing). So instead of working in Flash, my main Flash class is not running in Flash. Instead, I'm bringing all of my Flash assets in via an SWC. This gives me the advantage of compiling straight in FlashDevelop (and not having it switch to Flash, in fact Flash does not even have to be running). Plus, my compiles are faster. But there is one downside, now instead of my Flash symbol extending an AS3 class, I'm having my AS3 class extend the symbol. This means any named instances in the class are in the symbol instead of in the AS3 class, so I no longer have that reminder of the declaration at the top of the class. The instance is still declared and still appears in the code completion, but it just does not feel quite as good. Overall, though, this approach weighs in feeling like a better way to go.

7 comments:

  1. This is my preferred workflow (SWC from Flash CS3, building from FlashDevelop using Flex SDK).

    A tip for not being being annoyed by assets classes is to give to follow Flash CS3 components assets naming convention:
    - fl.controls.Button
    - Button_upSkin
    - Button_downSkin
    - etc.

    BTW you can event give the assets a name including a package (ie. assets.SymbolName, assets.OtherSymbol, etc), so they will not appear in all completion lists.

    ReplyDelete
  2. Thanks Philippe, it is good to hear other folks use this method. I really like it.

    How does the naming convention for components prevent being annoyed by the assets?

    I like your tip on adding a package to an asset's name, that's brilliant!

    ReplyDelete
  3. This naming convention will help identifying graphics vs classes and makes clear who owns who.

    Also, with next FlashDevelop release, the completion will favor the class if you type its name completely (ie. typing "Button" will pick fl.controls.Button vs Button_upSkin & co).

    Now that I think about it, adding a prefix to symbol names will be an even better help for code completion (ie. assets.mcSymbolName, swc.bmpImageName, etc).

    ReplyDelete
  4. That's great info! Are you _the_ Philippe of FlashDevelop?

    BTW, one of the things I love about FlashDevelop is the way the completion works. It is hard to describe, but it seems very sophisticated. For example, I can start typing "mou" and it will find all the the classes with those letters, then type "v" and it further narrows the list to those items that have "mou" and "v". Very handy.

    In fact, the only real feature I miss in FlashDevelop is drag and drop of text.

    ReplyDelete
  5. Yep that's me - the code completion is quite sophisticated so it takes time to fine tune (next release will be better).

    ReplyDelete
  6. The completion is so good right now, much better than FlexBuilder or other similar tools. Each release of FlashDevelop is like Christmas. There are always nice, well thought out, features. I'm a huge evangelist of FlashDevelop. Thanks for visiting!

    ReplyDelete
  7. I have to retract my earlier comment about FlashDevelop missing drag and drop. Either it was just added with beta 7 or it never worked for me until I installed beta 7, but now it does!

    ReplyDelete