static var moversList : Mover[];
function AddMoverToThatList(mover : Mover)
{
var newList : Mover[] = new Mover[moversList.Length + 1];
for (var i : int = 0; i < moversList.Length; i++)
{
newList[i] = moversList[i];
}
newList[moversList.Length] = mover;
moversList = newList;
}
Secondly, if you’re going to be altering the array, you really should use the List<> class instead. It automatically resizes and manages a wrapped builtin array as needed:
static var moversList : List.<Mover> = new List.<Mover>();
moversList.Add(someNewMover);
moversList.Add(someOtherMover);
for (var i : int = 0; i < moversList.Count; i++)
{
Debug.Log("Mover: " + moversList[i]);
}
moversList.RemoveAt(1);
//note, this might be "foreach", not sure with JavaScript
for(var currentMover : Mover in moversList)
{
Debug.Log("Mover: " + currentMover);
}