Well, Array.splice takes two parameters, and you didn't get either of them right.
Array.splice(startIndex:Number, length:Number);
What you should do is
var collisiondetection:Collision=new Collision();
var bulletArray:Array = new Array();
var timer:Timer = new Timer(2000);
timer.addEventListener(TimerEvent.TIMER, testShots);
timer.start();
function testShots(e:TimerEvent):void {
var darkShot:DarkShot = new DarkShot();
addChild(darkShot);
bulletArray.push(darkShot);
darkShot.x = darkTester.x;
darkShot.y = darkTester.y;
}
function enterFrameFunction(Event)
{
for (var i:uint=0; i<bulletArray.length; i++)
{
bulletArray[i].y += 3;
if(bulletArray[i].y >= 400)
{
this.removeChild(DisplayObject(bulletArray[i]));
bulletArray.splice(i,1);
i--;
continue;
}
if (collisiondetection.isColliding(player, bulletArray[i], 1))
{
trace("collision");
}
}
}
stage.addEventListener(Event.ENTER_FRAME, enterFrameFunction);
You could take this a step furthur, and create a DarkShot class that has a function called Update():Boolean. So your enterFrameFunction would look something like this:
function enterFrameFunction(e:Event):void
{
for (var i:uint=0; i<bulletArray.length; i++)
{
if(bulletArray[i].Update)
{
this.removeChild(DisplayObject(bulletArray[i]));
bulletArray.splice(i,1);
i--;
continue;
}
if (collisiondetection.isColliding(player, bulletArray[i], 1))
{
trace("collision");
}
}
}
.... Inside the DarkShot Code
public function Update():Boolean
{
this.y += 3;
if(this.y >= 400)
{
return true;
}
return false;
}