Im removing one array from an array of arrays unto an empty array
var _open:Array = [[x, y]];
var _closed:Array = [];
_closed.push(_open.splice(0, 1));
which leaves me with array _closed being:
[[[x, y]]]
Does anyone know why? Because if I push something without using splice function I get what i expected, no extra nesting. For example:
_closed.push([8,13]);
// _closed is [[8,13]]
By the way, tracing (arrays mostly) in AS3 can get really annoying, so im using this function to know if there is some nesting in arrays:
public static function traceArray(aArray:Array):void
{
for (var t:Object in aArray) {
trace(t + " : " + aArray[t]);
if (typeof(aArray[t]) == "object") {
traceArray(aArray[t]);
}
}
trace();
}
Yeah, if you look at the docs, you can see that
Array.splicereturns an array, not an element of an array (even if the splice is only of length 1).This will do what you want, though may not be the solution you are after:
What might suit your needs more is to use
or
Depending on whether you would want the first or last element
_openhas more than one element. Though from the names _open and _closed, I am guessing you need to pull an element from an arbitrary position in _open (once it is closed)… and for that, you should go with the first solution.