Hello, Flex

The Flex beta is live now at Adobe Labs.  I grabbed it last night and created my first Flex app this morning.. so far so good.

I created a simple mortgage calculator application as my first real Flex app.  Click the link to run it – if you don’t have the appropriate player it should offer to install it (if that doesn’t work, let me know).

Some notes from my short experience with Flex Builder:

It does a great job with IntelliSense in the XML view.  I was surprised to see it pop up IntelliSense when I was writing a handler inside the click= event for an object, but the editor is smart enough to realize that I’ve typed the name of an event handler for the object whose node I’m editing, so the text inside the quotes is code and should be treated as such.  Very handy.

You can mix script and declarative objects in code very easily, including the curly brace mechanism for referencing variables.  I was trying to figure out how to turn a Number into something I could display as currency and I found the CurrencyFormatter object.  I added one of these to my MXML source, but now how do I reference it?  Turns out it was easier than I expected.

I wanted to format the text in the label that shows you your monthly payment as a currency.  I have a variable, monthlyPayment, that holds that value.  Not only do I not have to write code to bind that value to the label (because I can set the text attribute to automatically bind to it when it changes by saying text=”{monthlyPayment}”) but I can reference my currency object right in the same statment:  text=”{Price.format(monthlyPayment)}”.

This lets you drop an object into your application, configure it, and use it, without ever writing a line of code. 

The MXML source for my mortage app is here:  Mortgage.mxml.  I don’t think the actual formula for the montly payments is right, so don’t use it to make any financial predictions.