This is a tip that will seem obvious to anyone who has done any Flex development, but it's something that took me a little while to figure out and I still need to remind myself of it every now and then.
In a procedural language like C#, Java, or JavaScript/ActionScript, when you want to do something, you need to figure out what class to use or what static method to call.
In MXML, there's a third place to look for functionality you need - tags.
You can declare class in your MXML by inserting and defining a tag that creates the object you're going to work with, and then use it in your procedural code. For example, if you need to print a Number formatted as a currency, you could add a CurrencyFormatter to your code:
<!-- Declare a CurrencyFormatter and define parameters.--> <mx:CurrencyFormatter id="Price" precision="2" rounding="none" decimalSeparatorTo="." thousandsSeparatorTo="," useThousandsSeparator="true" useNegativeSign="true" currencySymbol="$" alignSymbol="left"/>
This does the procedural equivalent of constructing an object named 'Price' whose class is CurrencyFormatter, with the parameters specified. You can then use this object in your ActionScript code simply by calling Price.format(myNumber) to get the value formatted as a string.
Coming from a procedural background, this can take a bit of getting used to.
Hello, and welcome to MXMLtips. There isn't much to see here yet, but I'm working on that.
I'm just a software developer, who is very impressed with MXML. I'm also very happy to hear that Adobe has decided to make parts of Flex available for free.
This is a good move, because declarative programming is on the rise, and Microsoft is coming on strong with their XAML technology. Microsoft's technology is, of course, only provided on Windows platforms.
MXML provides a way to create a rich UI using a declarative syntax, and run it today on millions of Windows, Macintosh, and Linux based computers. There is massive potential here, and the fact that portions of it will be available for free just helps ensure it's success.
So this site is where I'm going to talk about my own progress with MXML, useful things I discover, and I'll also publish notes that anyone else submits. If you've come up with something that helps make working with MXML or Flex easier, submit it here using the 'Submit News' link on the left (you'll only see it if you're logged in).
I started this site using Joomla, but after a bit of wrestling with it, I've switched to b2evolution.
Thanks for dropping by!
I'm excited about MXML, and you should be too.
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| << < | > >> | |||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
If you don't have it, go get it!
Lin Lin's Tips for using Flex Builder 2.
There's great integration between MXML and Flex Enterprise Services. You can hook a listbox up to a data source and when the data source changes, that change is propagated all the way out to the listbox. It's a very cool infrastructure.
But sometimes you just want to hook up to an existing back end. Here's a good thread on the Macromedia forums with sample code posted by Mike Potter of Adobe.