I am trying to load the results of an array and I can’t figure it out. Basically what I am doing is sorting a list of 7 numbers from a “test”, dropping the lowest 4, and keeping the top 3. I then need to identify the top three by the letter associated to that number, and have the results display in three seperate dynamic text fields.
.nt1 would be the total number of times that “A” was selected, .nt2 would be the total number of times that “B” was selected, etc.
//------here is the code that I am using
var score_array:Array = new Array();
score_array.push({score:_root.nt1, letter:“A”});
score_array.push({score:_root.nt2, letter:“B”});
score_array.push({score:_root.nt3, letter:“C”});
score_array.push({score:_root.nt4, letter:“D”});
score_array.push({score:_root.nt5, letter:“E”});
score_array.push({score:_root.nt6, letter:“F”});
score_array.push({score:_root.nt7, letter:“G”});
score_array.sortOn(“score”, Array.NUMERIC);
for (i=0; i<score_array.length; i++) {
trace(score_array*.score+":"+score_array*.letter);
}
var topThree_array:Array = new Array();
var topThree_array = score_array.splice(4);
for (i=0; i<topThree_array.length; i++) {
trace(topThree_array*.letter);
}
//--------
when I test the script it works, and the results are accurate and show up in the output panel as exected:
0:E
0:F
2:A
6:D
6:C
6:B
8:G
C
B
G
When I am stumped is how to get the C, B, G to show up in their own text boxes as the sorted top 3 results. This is my first attempt at scripting this advanced…if anyone can help me that would be awesome, if you have a better way of getting the results - let me know - or if you can point me to a resource that will show me how to - that would rock.