Hello I am working on a flash game and I am almost finished with it . I just need to know how to remove a movie clip from an array when my character/ hero runs into it.
; <code
var FoodArray:Array = new Array();
var Ftimer:Timer = new Timer(999,1);
stage.addEventListener(Event.ENTER_FRAME, spawn2);
function spawn2(e:Event):void {
if(FoodArray.length<10)
{
Ftimer.addEventListener
(TimerEvent.TIMER, Foodtimer);
}
Ftimer.start();
}
function Foodtimer(evt:TimerEvent):void{
var food_mc:food = new food();
food_mc.x = Math.floor(Math.random()*(500+1));
food_mc.y = Math.floor(Math.random()*(625+1));
addChild(food_mc);
FoodArray.push(food_mc);
trace(FoodArray.length);
checkhit();
}
function checkhit2():void {
//step 1: make sure array exists
if(FoodArray!=null && FoodArray.length!=0)
{
//step 2: check all enemies against villain
for(var i:int = 0;i < FoodArray.length; i++)
{
//step 3: check for collision
if(char_mc.hitTestObject(FoodArray[i]))
{
}
}
}
>