Is using [i] in variable callouts possible? (part 2)

I have posted the following question before:

[COLOR=blue]ok, so I know that you can use * callouts in for or while loops where “i” is a variable number that increments such as in the following example

answerTxt0.text = test.childNodes.attributes.name;*

but is it possible to do the same thing on the variable side?

if I was to create several variables like the following:
[/COLOR][COLOR=blue]correct0 = “”;
correct1 = “”;
correct2 = “”;
correct3 = “”;

etc.

can I make a call in a for loop to have the variable name increment as well? (see the following)

correct = question.attributes.correct;**

if anyone knows if this is possible, or if there is a work around, please advise - it is very much appreciated.

This one line of code would save me over 40 lines of code.[/COLOR]

[COLOR=black]Krilnon and Creatify were nice enough to help me and solve my problem:[/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=blue]Using ‘*’ won’t work, but something like this[“correct”+i] = “”; would work, if this was indeed the correct scope.[/COLOR]

[COLOR=black][/COLOR]
The code above did work and greatly helped me. However, I have come into a second problem regarding the same issue. I am trying to replace the following code:

for (j = 0; j<answer.length; j++) { //Loads Available Answers into Corresponding Text Fields
** if (j == 0) {
answerTxt0.text = test.childNodes*.childNodes[j].attributes.name;**
// answerTxt0 is a text field on the stage
** } else if (j == 1) {
answerTxt1.text = test.childNodes*.childNodes[j].attributes.name;
} else if (j == 2) {
answerTxt2.text = test.childNodes*.childNodes[j].attributes.name;
} else if (j == 3) {
answerTxt3.text = test.childNodes*.childNodes[j].attributes.name;
} else if (j == 4) {
answerTxt4.text = test.childNodes*.childNodes[j].attributes.name;
} else if (j == 5) {
answerTxt5.text = test.childNodes*.childNodes[j].attributes.name;
}**
}

with this code:

for (j = 0; j<answer.length; j++) { //Loads Available Answers into Corresponding Text Fields
** this[“answerTxt” + j] = test.childNodes*.childNodes[j].attributes.name;
trace("Text = " + this[“answerTxt” + j]);
}**

Now the weird thing here is that (using the trace) I am able to get the correct values the way I want them in the output window:

Text = Conus medullaris
Text = Anterior dorsal roots
Text = Cauda equina
Text = Filum terminal
Text =
Text =

However, they are not filling the text fields on the stage. Now, the only thing I can figure out here is that when I was able to get the tighter code to work before (see code answer above in blue), I was storing the values into a variable and now I am trying to store the values into dynamic text fields. Using the code above (with all the “if” statements) does work but I am trying to learn how to write cleaner and tighter code. Any help on this would be greatly appreciated!

Sorry for the long description… just trying to be as clear as possible.