Question
Displaying Arrays in text boxes - URGENT!!
Hello i am wanting to display the full content of an array in
a text field. However this displays a comma between each array
value which i dont not want.
How do i get rid of this?
The follow is the code i am using:
for (i=0; i<gNumOfQuestions; i++) {
if (gCorrectAnswers == gUserAnswers) {
gScore += 1;
userResult = (i+1)+" ("+gUserAnswers +") "+"= right\n";
textOutput.push(userResult);
if (i>1) {
userResult;
}
} else {
userResult = (i+1)+" ("+gUserAnswers+") "+"= wrong\n";
textOutput.push(userResult);
}
}
results_mc.results_txt.text = textOutput.join();
please note that my text box is held within a movie clip and the "i" has 1 added to it to giv the correct question number because of the way arrays are indexed from 0 upwards.
The following is the output i get:
1 (d) = wrong
,2 (d) = right
,3 (d) = right
,4 (d) = wrong
,5 (d) = wrong
,6 (d) = wrong
,7 (d) = wrong
,8 (d) = wrong
,9 (d) = wrong
,10 (d) = wrong
,11 (d) = wrong
,12 (d) = wrong
,13 (d) = right
,14 (d) = right
,15 (d) = right
,16 (d) = right
,17 (d) = wrong
,18 (d) = wrong
,19 (d) = wrong
,20 (d) = wrong
,21 (d) = wrong
,22 (d) = wrong
,23 (d) = wrong
,24 (d) = wrong
,25 (d) = wrong
,26 (b) = wrong
,27(d) = wrong
,28(b) = wrong
it is the commas at the start of each line i want to lose.
i was thinkin about using the substr function but not sure how i could use this as i dont know how to use it to delete the first char from a line.
any help would be greatly appreciated.
thanks
lee
How do i get rid of this?
The follow is the code i am using:
for (i=0; i<gNumOfQuestions; i++) {
if (gCorrectAnswers == gUserAnswers) {
gScore += 1;
userResult = (i+1)+" ("+gUserAnswers +") "+"= right\n";
textOutput.push(userResult);
if (i>1) {
userResult;
}
} else {
userResult = (i+1)+" ("+gUserAnswers+") "+"= wrong\n";
textOutput.push(userResult);
}
}
results_mc.results_txt.text = textOutput.join();
please note that my text box is held within a movie clip and the "i" has 1 added to it to giv the correct question number because of the way arrays are indexed from 0 upwards.
The following is the output i get:
1 (d) = wrong
,2 (d) = right
,3 (d) = right
,4 (d) = wrong
,5 (d) = wrong
,6 (d) = wrong
,7 (d) = wrong
,8 (d) = wrong
,9 (d) = wrong
,10 (d) = wrong
,11 (d) = wrong
,12 (d) = wrong
,13 (d) = right
,14 (d) = right
,15 (d) = right
,16 (d) = right
,17 (d) = wrong
,18 (d) = wrong
,19 (d) = wrong
,20 (d) = wrong
,21 (d) = wrong
,22 (d) = wrong
,23 (d) = wrong
,24 (d) = wrong
,25 (d) = wrong
,26 (b) = wrong
,27(d) = wrong
,28(b) = wrong
it is the commas at the start of each line i want to lose.
i was thinkin about using the substr function but not sure how i could use this as i dont know how to use it to delete the first char from a line.
any help would be greatly appreciated.
thanks
lee