Adding Attributes to an XML Element
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var example:XML = <example><someElement/></example>;
example.someElement.@number = 12.1;
example.someElement.@string = "example";
example.someElement.@boolean = true;
example.someElement.@array = ["a", null, 7, undefined, "c"];
trace( example );
example.someElement.@["bad-variable-name"] = "yes";
example.someElement.@["color" + num] = "red";
}
}
}
Related examples in the same category