Hi, i'm having some problems with as3
var eventChildren:XMLList = eventInput.channel.children();
var nr:Number;
nr=0;
for each (var eventInfo:XML in eventChildren) {
nr++;
trace(eventInfo.title);
var ev="ev"+String(nr);
var titl="title"+String(nr);
trace(ev);
trace(titl);
var newEV:Object = Object(ev);
var newTITL:Object = Object(titl);
trace(newEV);
trace(newTITL);
newEV.newTITL.text=eventInfo.title;
}
}
this is my code, i'm trying to set the title value for every child instance of eventChild, as i am new to action script in general, and action script 3 in particular i don't really know what i'm doing wrong here. I'm trying to set the text for ev1.title1, ev2.title2, etc. from values in eventChildren like this : first child, sets ev1.title1, second ev2.title2 and so on. Any ideas on what i should change in the code or where to look for some information ?
edit : thank you for the help, both answers took me to the right solution :
for each (var eventInfo:XML in eventChildren) {
nr++;
trace(eventInfo.title);
var ev="ev"+String(nr);
var titl="title"+String(nr);
//trace(ev);
//trace(titl);
var oTitle:Object = {}; // create object for the field titleXX
oTitle[titl] = {text:eventInfo.title}; // create and assign the field text to a new object
allFields[ev] = oTitle; // assign the title object to the field evXX
}
ev1.title1.text=allFields.ev1.title1.text;
ev2.title2.text=allFields.ev2.title2.text;
ev3.title3.text = allFields.ev3.title3.text;
ev4.title4.text=allFields.ev4.title4.text;