That was a fun one to track down. Using an index of -1 for Array.splice
inserts the element just before--not after--the last element. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4845 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -35,7 +35,7 @@ public class StreamableArrayList
|
|||||||
|
|
||||||
public function add (item :Object, index :int = -1) :Boolean
|
public function add (item :Object, index :int = -1) :Boolean
|
||||||
{
|
{
|
||||||
_array.splice(index, 0, item);
|
_array.splice((index == -1) ? _array.length : index, 0, item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,10 +48,8 @@ public class StreamableArrayList
|
|||||||
{
|
{
|
||||||
var other :Array = getArray(otherList);
|
var other :Array = getArray(otherList);
|
||||||
|
|
||||||
// splice each element in at the index
|
// splice the array in at the index
|
||||||
for (var ii :int = other.length - 1; ii >= 0; ii--) {
|
_array.splice((index == -1) ? _array.length : index, 0, other);
|
||||||
_array.splice(index, 0, other[ii]);
|
|
||||||
}
|
|
||||||
return (other.length > 0);
|
return (other.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user