Archive for January, 2006

Flex Beta 2 and Free Flex SDK

It’s all true. We’ve decided to release a free version of the Flex SDK. We haven’t decided exactly what’s going to be in it yet, but at a minimum, a compiler and the framework — everything you need to build Flex 2 applications. We’re also going to release a free version of Flex Enterprise Services that will be limited by the number of connections it allows, and will only run on a single server. Of course, Flex Builder 2 and the full version of Flex Enterprise Services 2 won’t be free, but now anyone will be able to get started building Flex 2 applications at no cost whatsoever. This is all we really know at this point, but I’ll post more details when I have them.

Also, Flex Builder 2 and Flex Enterprise Services 2 will go into public beta tomorrow, so get ready. Some of the new features include:

  • View source support. If you want to share the source of your app, just enable the view source option when publishing, and Flex Builder 2 will automatically generate beautifully formatted source code for all the world to see along with a "View Source" option in the context menu. This is amazingly slick.
  • Player detection.
  • History management.
  • Automatic import organization.
  • Code collapse.
  • Outline view.
  • Tons of other stuff.

If you’re still getting up to speed on Flex, I made a post the other day entitled "Clarifying the Term Flex" which describes in detail all the different components of Flex. I’ll let you know when the beta is available for download, or you can just keep an eye on Adobe Labs (rss).

Programmatically Determining a Site’s Language

I was having a conversation with a couple guys the other day about data aggregation, and the topic of language came up. They wanted to know how you can programmatically determine what language a site is written in (language as in spoken and written language, not computer language). Off the top of my head, I guessed one could uncover clues in the site’s HTTP headers, character encoding, or by geocoding the site’s IP address.

It turns out to be a harder problem to solve than I initially thought. HTTP headers are really no more help than a site’s character encoding which really isn’t much help at all since UTF-8 can pretty much encode any language there is. And geocoding an IP address is really nothing more than a hint for all the regular reasons geocoding IP address doesn’t always work, and for the additional reason that a server being in a particular country doesn’t really tell you anything about the language the sites on the server are written in (I used to live in Japan, but never posted a single thing in Japanese).

I did a little research, and it looks like folks like Google use very complex techniques for determining a site’s language like comparing characters and words against known sets of characters and words in a database. This seems like a reasonable approach, but not one that I could implement in a reasonable amount of time (like a couple of hours), so I did what I always do when faced with a very complex problem: I looked for an obvious and simple solution.

Continue reading…

Clarifying the Term “Flex”

I’ve noticed some confusion out there around the term "Flex". The term has evolved as our technology has evolved, and actually means something very different now than it did even just a few months ago. If you’re a little confused about what we mean when we say Flex or Flex 2, this should clear things up.

I’ve decided to break this post down into two sections: Initial Flex Products, which describes how we started off using the term Flex, and Current Flex Products, which describes what Flex means today.

Initial Flex Products

  • Flex 1.5: Flex 1.5 is probably what most of you think of when you think of Flex: an enterprise level presentation server. You write MXML, move it over to a server, and Flex compiles the MXML into a SWF, and serves up your application’s presentation layer. You can compile your MXML "off-line" and just copy the resulting SWF over to your server, as well. Once your Flex application is running on the client, you can use web services or AMF to communicate with the server.
  • Flex Builder 1.5: Flex Builder 1.5 is an authoring environment for Flex 1.5. It is based on the Dreamweaver code base, and gives you things like design and code view, syntax highlighting, code hinting, and application preview.

Current Flex Products

  • Flex 2: Flex 2 is an umbrella term which refers to all the technologies in the Flex 2 product line including the Flex Framework, Flex Builder 2, and Flex Enterprise Services 2.
  • Flex Framework 2: With the next generation of Flex technology, we have decoupled the framework from the products themselves. The Flex Framework consists of MXML (an XML-based language for declaratively building your applications), class libraries, components, containers, and effects. The Flex Framework can be used to build and style Flex applications without a server or any particular IDE. In fact, all you actually need to build Flex applications is the Flex Framework and the Flex compiler, both of which can be used on their own. Find out more about the Flex Framework here.
  • Flex Builder 2: Flex Builder 2 is an entirely new product, and has almost nothing in common with Flex Builder 1.5. Flex Builder 2 is a brand new RIA IDE built on top of Eclipse, and is the easiest and most powerful way to build Flex applications. Flex Builder 2 makes developing Flex applications much simpler with features like an integrated compiler, code hinting, debugging, design view, source control system integration, and tons of other features. It will be available as both a standalone application, and as an Eclipse plugin that you can use with your existing Eclipse installation. Find out more about Flex Builder 2, and download an alpha release, here.
  • Flex Enterprise Services 2: Flex Enterprise Services is basically the next generation of the Flex 1.5 server, but with tons of new functionality like automated testing, enterprise messaging support (which provides a publish/subscribe messaging infrastructure), and the Flex Data Services, which automatically synchronizes data manipulated locally with data on the server. Find out more about Flex Enterprise Services 2 here.

Other Flex-related Technologies

  • Flex Charting Components 2: The Flex Charting Components 2 are a new set of customizable Flex components which provide very slick data visualization capabilities. Think of them as an extension to the Flex Framework. You can use them with Flex Builder 2 and Flex Enterprise Services. Find out more about the Flex Charting Components 2 here.
  • Flex Compiler: Although Flex Builder 2 and Flex Enterprise Services both have the Flex compiler built in, it can also be used outside of either product. The compiler can be used for compiling MXML applications or ActionScript projects from the command line. Find out more about using the Flex compiler and Flex framework from the command line here and here.
  • ActionScript 3: ActionScript 3 is the core of the Flex Framework. Although the syntax is similar to ActionScript 2, it is more object-oriented, more strongly typed, and because it executes inside a brand new virtual machine, it is much faster than ActionScript 2. ActionScript 3 is fully compliant with the ECMAScript 4 proposal (the standard JavaScript 2.0 is based on), and includes things like E4X and regular expressions. Find out more about ActionScript 3 here.
  • Flash Player 8.5: Flash Player 8.5 is the newest version of the Flash Player, and is still in alpha. It is the client runtime for Flex 2 applications. The biggest addition to Flash Player 8.5 is the ActionScript 3 virtual machine. Find out more about Flash Player 8.5 here.

If you have any Flex related questions, or if anything in this post isn’t clear, let me know.

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

Flash and Ajax: Happy Together

Path recently released their Flash/JavaScript
Date Slider
under a
Creative Commons License.  It’s a very slick component that
they use with Measure
for visually selecting date ranges, and which
shows excellent interoperability between Flash and JavaScript. It uses
the JavaScript /
Flash Integration Kit
as the bridge between Flash and
JavaScript, and I think integrates very nicely into HTML/Ajax
applications. From the Date Slider site:

The date slider is a Flash visualization that Measure
uses as one way to navigate the site. We are happy to provide a version
of this date slider to the public… SWF version with the
ability to customize the look & feel of the slider as well as
the location and name of
the XML file.

What I really find interesting about this project is that it
is a standalone component which integrates Flash and Ajax very
seamlessly, and therefore tends to blur the line between the two
technologies. Too often I read about the “Flash vs Ajax”
debate when the reality is that Flash is very Ajax friendly, especially
with the new ExternalInterface

it in action.