If index scattered numbers with Object, it does a string comparison of its keys, so if you put in a list of numbers to sort and iterate, they don’t come out in order, because it sorts the numbers as text.
obj[9] = “A”;
obj[25] = “B”;
obj[60000] = “C”;
for each (var item:Object in obj)
trace( item );
B
C
A
I thought I’d use a Dictionary to look up (and sort in) a list of numbers, because
it compares as the objects. But alas, it sorts alphabetically, too.
I would do something like (obj[int(9).toRightString(10,3)] = “A”), except there doesn’t appear to be anything NATIVE (i.e. doesn’t run at 1/10th speed for being interpreted code) to format a right-justified number padded with zeros on the left.
Even Adobe’s ‘toString()’ Flex example is broken…
var r:uint = 250;
var g:uint = 128;
var b:uint = 114;
var rgb:String = "0x" + r.toString(16) + g.toString(16) + b.toString(16);
trace(rgb); // 0xfa8072
Because if r, g, or b are less than 16, the padded zero won’t be included, and the displayed value will be invalid.
Frustrating.