Posts in Category "Flex"

A Ruby Script for Compiling Flex Applications

There have been a lot of posts recently about how to compile
Flex applications and ActionScript projects from the command line (on
Windows, Mac, and Linux).  Mike Chambers has a
nice summary
which points to all the information you need to
get going, and has a
bash script
which wraps the mxmlc compiler to make
compilation easier.

I have some specific compilation needs, however, so I decided
to write a
Ruby script
to wrap the mxml compiler (I’m not a huge fan of
bash once my scripts reach a certain level of complexity). Once you
have the
Flex environment set up, just download
the script
, make sure it’s in
your path, configure it, and you can compile like this:

% mxmlc.rb MyApplication.mxml

The script has the following flags:

  • -h
    Help.  Prints out this help message.
  • -t Tail. After compilation,
    tails the file specified by the
    TAIL_PATH variable. (Useful for debugging your application.)
  • -o Open. After compilation,
    opens the generated swf in the
    application specified by the OPEN_APP variable. (This should probably
    be something like ‘firefox’ or ‘safari’.)
  • -s Show. Show the compilation
    command rather than actually
    running it. Useful for debugging if it’s not working like you expect it
  • -c Clean. Removes cache files
    before compilation so you
    compile the project completely from scratch.

Before running the script, you have to configure it by
defining the following variables at the top:

  • FLEX_PATH: The path to your
    Flex library installation.
  • AS_LIB_PATH: Path to your
    ActionScript libraries. In other
    words, your classpath. You can specify multiple directories by
    separating them with a ‘:’ character. You can also add a ‘$’ character
    anywhere in any of the paths which essentially acts like a wildcard.
    For instance, if I added the directory
    /Users/cantrell/projects/$/src/actionscript, then the script would
    iterate through all the directories in /Users/cantrell/projects and add
    all those directories, plus /src/actionscript to the classpath. It’s an
    easy way to include an entire source tree with one path. (If the
    generated directory doesn’t actually exist, the script automatically
    leaves it
  • TAIL_PATH: The path to the
    file you want to tail if you
    pass in the -t flag.
  • OPEN_APP: The application you
    want to open the resulting
    swf file in if you pass in the -o flag.

Let me know if you have any problems getting it to run. It was
written and tested under Ruby version 1.8.2 which should already be
installed on your Mac. To get the alpha version of the Flex Framework
and the compiler, check out Flex
Builder 2 on Adobe Labs

ActionScript 3.0 Presentation and Examples

Back in November, Danny
and I did a small world tour  to talk to our
international communities about ActionScript 3.0.  Danny did
Europe, and I did Asia. We put together a PowerPoint presentation
(which you can view
), and several good code examples (which you can download
).  The presentation covers:

  • Regular Expressions.
  • E4X. The new and very simple way to create, parse, and
    query XML in ActionScript 3.
  • ExternalInterface API. Allows your Flash content to
    communicate with its container (usually the HTML page via JavaScript)
    without any additional libraries.
  • File upload. Shows how to upload a file using Flex and save
    it on the server using ColdFusion. (File upload is actually already
    available in Flash 8.0, but this is a Flex 2 example).
  • Data types. Lists all the ActionScript 3.0 data types and
    their default values.
  • Operators. Demonstrates some of the ActionScript 3.0
  • Packages. Demonstrates how packages work in ActionScript
  • Rest arguments. ActionScript 3.0 supports a concept of
    “rest arguments” which you allows you to make some argument required,
    and also handle an arbitrary number of additional arguments.
  • Proxy. The flash.util.Proxy object is a more powerful
    version of __resolve.
  • Reflection. Shows how to introspect ActionScript 3.0
  • Timer. Shows how to execute code at a specified interval.
  • The new display list API.

To run these examples and build your own Flex 2.0
applications, you’ll need to grab the Flex
Builder 2
alpha from Adobe

CFEclipse and Flex Builder 2: Happy Together

I now do all my Flash development in Flex Builder 2. No exceptions. But I still use another installation of Eclipse for other types of development (ColdFusion, Java, HTML, JavaScript, etc.). Yesterday, I ran into a situation where I needed to embed a small Flex application in a custom HTML page, so tried installing CFEclipse into Flex Builder 2, and it seems to work perfectly. It’s not guaranteed to work, and I supposed it could break in the future, but for now, I’m a very happy developer.

Update: I should qualify that I’m talking about the standalone version of Flex Builder 2. The plugin version will definitely work with CFEclipse.

Video of Flex Announcement at Web 2.0

Although you’ve probably already seen the Flex 2.0 product family announcement, you can now see a video clip of Kevin Lynch actually delivering the official announcement at Web 2.0. Mike Chambers got Kevin’s entire presentation on tape. It’s only about 15 minutes long, but Kevin packs in a ton of good information, including building a very nice little application using Flex Builder 2 (Zorn) in only about 5 minutes. The clip is available as Flash video both on Mike’s blog and on Google Video. If you get seasick, brace yourself for about the first 30 seconds, but after that, it stabilizes.

Non-commercial Flex Licenses Now Available

Flex just became much more accessible. If you’re a student, educator, or if you run a non-commercial, non-institutional website, you can now use Flex for free in a production environment. From Macromedia’s site:

This software license will enable individuals, including students, technology educators and individual developers to build and deploy Flex applications at no cost (except for a small shipping and handling fee). Participants also receive 1 license of Macromedia Flex Builder, the Macromedia IDE for Flex.

Find out more (including exactly who qualifies) by reading the Flex FAQ.

Flex Builder (aka Brady) Goes Live

If you’re doing Flex development, you will be happy to hear that Flex Builder — the Flex IDE we’ve been calling “Brady” — is now live. There’s tons of information about Brady on the site, which I’ll link to below, but I’ll give you the lowdown here to save you a few clicks.

Flex Builder is an IDE for developing Flex applications. It doesn’t just do MXML syntax highlighting and provide things like tag insight, though; it’s actually very tightly integrated with the Flex server and really streamlines Flex application development.

As you might have guessed, Flex Builder is for Flex developers, and really specializes in and focuses on Flex application development. It’s not a general purpose IDE like Dreamweaver or Eclipse.

Flex Builder comes with Flex. The Flex Builder trial comes with the Flex trial, and five licenses of Flex Builder come with every Flex license. (If you already purchased Flex, don’t worry — you can still get your Flex Builder licenses. See links below.)

You don’t need Flex Builder to build Flex applications. You can keep using Dreamweaver, Eclipse, Emacs, Vim, or whatever you like to use. If you’re using WIndows for Flex development, though (Flex Builder is only available on Windows), you might want to give it a try. I saw a demo of it last week, and it will really make Flex developers’ lives easier.

That’s Flex Builder at a high level. For more information, see:

Excellent Review of Flex

And by “excellent”, by the way, I don’t mean that it’s unconditionally glowing. I mean that it’s thorough, accurate, and objective.

In Peter Ent’s review of Flex, he discusses the processes and challenges of building five very different applications using Flex with J2EE back-ends. For each application, Peter describes the project, provides links to screenshots and zip files containing the source code, and discusses the benefits and challenges of using Flex (along with other technologies like Flash Communication Server, and even the charting components from B-Line Express). At the end he provides a short analysis of Flex as an alternative to JSP, and summarizes the processes of coding in MXML, debugging Flex applications, and using style sheets with Flex. And, of course, he has a few comments on Flex documentation, as well.

This is one of the most honest, straightforward, and comprehensive reviews of Flex I’ve seen so far, and it’s obviously written by someone who knows the technology he’s working with. (It also doesn’t hurt that it’s relatively short and very easy to read, as well.) If you looking for a detailed, objective perspective on Flex technology, this is it.

Flex 1.0 Updater 2 Is Live

Just wanted to mention that the Flex 1.0 Updater 2 just went live. Lots of good stuff, according to the release notes. If you use Flex, get this update!

Curious About Brady?

Macromedia just published a new Logged In article with a lot of great information on Brady, Macromedia’s new Flex IDE (which just entered final beta). It contains some pretty detailed descriptions, and several good screenshots. Here’s a little taste:

Brady is the Macromedia IDE for Flex application development. Designers and developers can be more productive building Flex applications through tight integration between the IDE and the server. Developers can learn MXML and type code more quickly and accurately using Brady’s code hinting feature. More visually-oriented programmers can use the drag-and-drop Design view to quickly lay out Flex interfaces and style them using CSS….

Changing The Flex Preloader

I’ve seen a few people ask if there is any way to turn off the default preloader in Flex applications. You can do so using the “usePreloader” attribute of the Application tag, like this:

<mx:Application xmlns:mx="" usePreloader="false">

But why turn it off? It’s so nice! I can understand wanting to customize it, though, which you can do using the “preloader” attribute of the Application tag. For more information on customizing the Flex application preloader, search the Flex LiveDocs for the term “preloader” and you’ll get all the information you need.