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.
http://mxmltips.com/htsrv/trackback.php/26