ArrayCollection weirdness
I ran into a head-scratcher today...
How can this code:
give this output?
-1 true
rows is an ArrayCollection with one element. partition.placeholderRow exists and is a valid object. I haven't mucked around with rows.source at all.
Answer follows in comment (so you don't peek ahead and cheat!)
How can this code:
var index:Number = rows.getItemIndex(partition.placeholderRow );
trace( index + " " + (rows.getItemAt(0) === partition.placeholderRow ) );
give this output?
-1 true
rows is an ArrayCollection with one element. partition.placeholderRow exists and is a valid object. I haven't mucked around with rows.source at all.
Answer follows in comment (so you don't peek ahead and cheat!)
Labels: Actionscript
1 Comments:
The array collection had a custom sort order applied.
That custom sort has a compare function set. The compare function didn't handle the a==b element correctly.
Now, the ArrayCollection class will use your compare function when you call getItemIndex so it can do a quick binary search instead of a long linear search.
So using our bad sorting compare function, it never found anything equal, and you got that weirdness.
By
Marc, At
2/28/2008 9:36 AM
Post a Comment
Subscribe to Post Comments [Atom]
<< Home