I mentioned in my last post that I’ve played around with Flex 2 and FlashDevelop. I wanted to briefly follow up on that by sharing what I added to my toolbar in FlashDevelop. There are a few posts on the FD forums which go over how to add your own toolbar or menu options which is super easy since they’re driven off of some xml files.

Assuming you already know what Ant is and you have it installed, you can easily create a build.xml file which will send off your mxml or actionscript to the Flex compiler, magically producing a finished Flex app. I wanted to add a shortcut to my toolbar in FD so that I didn’t have to keep an extra window open to run ant so I add the following to my ToolBar.xml file in FD:

<button label="ANT" click="RunProcessCaptured" image="23" tag="C:\windows\system32\cmd.exe;/k ant" />

Add it wherever you like, I just added it right next to the command prompt button which I basically just copied. All I added was the /k ant which tells the command prompt to run the command “ant” when it launches.

Update: I changed the above code snippet to reflect some input from Philippe. Now the output from the command prompt window is directed to the output panel in FD. You might have to change your path to cmd.exe, but most likely not.

Regarding the build file, I just copied the one Sam made and modified it for my own use.

If you want to copy mine to get started, here it is:
build.xml

The property name “source” refers the name of the mxml or as file you want to send to the compiler and “ext” is the extension, since you can send either an as file or an mxml.

14 Responses to “Compiling Flex2 from FlashDevelop”

  1. Campbell Says:

    Wow cheers for pointing that one out bro, I have been hoping something would happen here. Good work and cheers for sharing.

  2. Philippe Says:

    You can also have ANT’s output captured in the output panel:

  3. Philippe Says:

    (xml was stripped)
    button label=”ANT” click=”RunProcessCaptured” tag=”C:\WINDOWS\SYSTEM32\CMD.EXE;/k ant”

  4. Tim Says:

    Sweet. I haven’t taken the time to learn what all those attributes did. It was simply a case of “maybe I’ll copy this button and change it a little”.

  5. Lance Says:

    Thats great! I just started thinking about doing the same thing so this example will help me a lot. Thanks!

    Any chance that someone has started work on an Ant or NAnt task for the Flex2 compiler?

  6. Ben Says:

    I don’t suppose FD has code hinting for MXML or AS3 yet, does it?

  7. Tim Says:

    Ben, it doesn’t support it right now, but it sounds like there will be an effort to add support for this when flex2 and as3 is released as a final candidate.

  8. valley Says:

    Will FD (or any other ide) allow debugging a Flex 2 project ?
    Since everything around Flex 2 will be free of charge (except the Builder)
    this theoretically should be possible.
    If efforts are made in this direction this would be great.

    Regards
    valley

  9. Tim Says:

    Good question. I’ve been wondering as of late what kind of development effort it will take to have an opensource debugger to compliment the free, standalone compiler. For serious Flex development, obviously one wouldn’t want to give that up so it remains to be seen whether serious flex development will happen outside of the builder.

    At least for me right now, I wouldn’t mind the lack of a debugger because I still have to get into the habit of using the one in the builder now! I still find my old flash habits of tracing out values of things sneaking into my development workflow. I’m trying to realize I don’t need to do some of these things anymore :)

  10. Josh Says:

    I’ve noticed that there aren’t many powerful visual debuggers for *any* language. It’s probably one of the more difficult parts of building a development environment. I know there’s some work on an AS2 debugger (though I don’t remember what it’s called). I’m curious how different the debug SWFs are for Flash 9 and AVM2.

  11. valley Says:

    Well the point is that my AS2 projects (using FAMES) currently have reached a size where it’s really hard to find and solve errors with trace statements.
    That’s why I would really appreciate an open source ide for Flex 2 projects that
    will allow comfortable debugging projects.
    With Flash 7 (and below) projects this wasn’t possible, as it seems, but I
    strongly hope that there will be an open description for the SWD (or whatever the name will be in Flex 2) files that can be used for debuggers outside FlexBuilder.
    If not, then I really have to think about purchasing FlexBuilder, since the debugger looks quite ok for me, but I would prefer an ide that costs nothing ;-)

  12. Compiling AS3.0 and Flex 2.0 from FlashDevelop using Ant (step by step ) at DEJA-VUE.NET Says:

    [...] Thank to Tim Walling (he opened the way) http://www.timwalling.com/2006/04/20/compiling-flex2-from-flashdevelop/ [...]

  13. Marcelo Says:

    Hi,

    I have a flex application, and I need to compile it to run with Flash Player 7.

    Someone can tell me if it’s possible to do, if it’s possible, how can I do that.

    Regards.

  14. Tim Says:

    Marcelo, Flex 2 requires Flash Player 9 since it uses Actionscript 3.

Leave a Reply