This is the object array target structure I am looking to create
myObject.myArray[0].data=value;
myObject.myArray[0].data2=value2;
myObject.myArray[1].data=value;
myObject.anotherArray[0].data=value;
myObject.anotherArray[0].data2=value2;
myObject.anotherArray[1].data=value;
myObject.anotherArray[1].data2=value2;
An Object (myObject) with an Array (myArray) of Objects;
I can do this fine manually, but what I am wanting to do is create this dynamically from xml data. All of which works fine done manually in code. This is my basic dynamic code:
var xml=xmldata;
do {
current:Object = new Object(); // the main object
var name:String=xml.nodeName; // ie - text
/// create an array in current with an object inside ie (current.text*.data)
set("current." + name, [{}]);
var node=xml.firstChild;
var i=0;
do {
for (attr in node.attributes) {
// this is basically what I am trying to replicate
// current.text[0].attr=node.attributes[attr];
//or current.text[0].id=16;
// All the variables work, I just can't get them to be placed inside
//the object inside the array
set(current[name+"["+i+"]."+attr], node.attributes[attr]); //no worky
//current[name+"["+i+"]."+attr]=node.attributes[attr]; //no
//this[current+name+"["+i+"]."+attr]=node.attributes[attr]; //nope
}
i++;
} while (node = node.nextSibling);
} while (xml = xml.nextSibling);
Anyone have any suggestions?
Thanks, Dusty