I quite like the new XML capabilities of AS3. E4X is really handy and it's really nice creating XMLs like this:
[code lang="actionscript"]
var myXML = new XML(
<data>
<wadus att="true">Hello World</wadus>
</data>
);
[/code]
But what do you do when you have to create an XML based on an object's properties or simply based on information set up at run time? Curly braces:
[code lang="actionscript"]
private var wadus:String="Hello World";
private var wadusAtt:Boolean=true;
var myXML = new XML(
<data>
<wadus att={wadusAtt}>{wadus}</wadus>
</data>
);
[/code]
Please note that you don't use quotes when setting up the attribute. I'm using this as part of HippoHX's GUI, you can see it
here.
I learnt this reading
AS3 E4X Rundown, go there for a much deeper look to E4X.
BTW, if you try to create 2 attributes with the same name in the same node the player simply stops (I guess it's throwing an exception). It would be great catching this up at compile time instead.