I want to create an object with nested objects inside of it whose objects has objects inside of those, like this simple structure:
var obj:Object = {
exercise : {
question0 : {}
question1 : {}
question2 : {}
question3 : {}
}
};
Then assigning those objects their properties dynamically with the contents of an XML like this:
for (var i:uint=0; i<4; i++) {
obj.exercise["question"+i].original = varXML.texts.exercise.question[i].original.@text;
obj.exercise["question"+i].example = varXML.texts.exercise.question[i].example.@text;
obj.exercise["question"+i].answer = varXML.texts.exercise.question[i].answer.@text;
}
This code works well; that's the way I know. However the number of question objects is dynamic and I'm not able to find a way to define the structure of the main object. So I don't want to have question0, question1, question2, question3, question4, etc declared from the beginning (without that I get an error).
Just doing this: var objSenTense:Object = {}; doesn't help either. How can I do this?
{ exercise : { data: ..., otherdata: ..., questions: []} }