Posted: December 16, 2009 at 6:46 AM by jbuda
Tags: Actionscript
I have started to do more XML work with Actionscript 3 and found myself needing to create an object of attributes from a node. A function may already exist within Actionscript to achieve this but i couldnt instantly see it, so i quickly created one in case anyone would find it useful.
package xml.utils {
public class XMLUtils {
public static function attributesToObject($xml:XMLList):Object {
var atts = new Object();
for (var i:int=0; i«$xml.length(); i++) {
atts[$xml[i].name().toString()] = $xml[i];
}
return atts;
}
}
}

twitpic photos