Flash game: need help

Hi, I’m currently trying to program a flash game using actionscript 3.0 where users would step on insects. Basically, I added multiple instances of insects movieclip and remove them by using hitTest function. When the mouse_mc. hitTestObject(insect), there were times the insect was not removed.

Here are the errors i encountered:

Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/swapChildren()
at SteppingGame/hitTest()
Error #1009: Cannot access a property or method of a null object reference.
at insectmc/onEnterFrameEvent_SF()

I have been cracking my head for the past few days and hope you guys could help me see what cause the problem.

Here’s my as3 code:
[COLOR=Blue]package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.ui.Mouse;
import flash.display.Sprite;
import flash.text.TextFormat;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.Event;

public class SteppingGame extends MovieClip
{
    
    //No. of resets
    private var noReset:Number = 0;

    //init score equal to 0
    private var hitscore:Number = 0;

    //my insects
    private var insect1:insectmc;
    private var insect2:insectmc;
    private var insect3:insectmc;
    private var insect4:insectmc;
    private var insect5:insectmc;
    private var insect6:insectmc;
    private var insect7:insectmc;
    private var insect8:insectmc;
    private var insect9:insectmc;
    private var insect10:insectmc;

    //my fishes
    private var fish1:fishmc;
    private var fish2:fishmc;
    private var fish3:fishmc;

    public function SteppingGame()
    {
        
    }

    private function startlevel1():void
    {
        
        showGameScore();
        stage.addEventListener(MouseEvent.CLICK, hitTest);
        stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseListener);
        insect1= new insectmc();
        insect2= new insectmc();
        insect3= new insectmc();
        insect4= new insectmc();
        insect5= new insectmc();
        fish1 = new fishmc();
        fish2 = new fishmc();
        fish3 = new fishmc();
        addChild(fish1);
        addChild(fish2);
        addChild(fish3);
        addChild(insect1);
        addChild(insect2);
        addChild(insect3);
        addChild(insect4);
        addChild(insect5);
        trace(getChildAt(0));
        StartCountDown();
    }

    public function mouseListener(event:MouseEvent):void
    {
        Mouse.hide();
        mouse_mc.x = mouseX;
        mouse_mc.y = mouseY;
        
    }

    public function hitTest(event:MouseEvent)
    {
        trace(insect1);
        var squish:SquashMC = new SquashMC();
        if (mouse_mc.hitTestObject(insect1))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect1.rotation;
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;

            removeChild(insect1);
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect2))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect2.rotation;
            removeChild(insect2);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect3))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect3.rotation;
            removeChild(insect3);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect4))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect4.rotation;
            removeChild(insect4);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect5))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect5.rotation;
            removeChild(insect5);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect6))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect6.rotation;
            removeChild(insect6);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect7))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect7.rotation;
            removeChild(insect7);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect8))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect8.rotation;
            removeChild(insect8);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect9))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect9.rotation;
            removeChild(insect9);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else if (mouse_mc.hitTestObject(insect10))
        {
            hitscore = hitscore + 10;
            squish.rotation = insect10.rotation;
            removeChild(insect10);
            squish.x = mouse_mc.x;
            squish.y = mouse_mc.y;
            addChildAt(squish,6);
        }
        else
        {
            insect1.newpos();
            insect2.newpos();
            insect3.newpos();
            insect4.newpos();
            insect5.newpos();
            insect6.newpos();
            insect7.newpos();
            insect8.newpos();
            insect9.newpos();
            insect10.newpos();
        }
        showGameScore();

    }

    public function StartCountDown():void
    {
        myText.text = "Time: " + String(timeLimit);
        timer.reset();
        timer.start();
        timer.addEventListener(TimerEvent.TIMER, timerHandler);
        timer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
    }

    //Check current time
    public function timerHandler(e:TimerEvent):void
    {
        myText.background = false;
        myText.text = "Time: " + String((timeLimit) - timer.currentCount);

    }

    //Time is finished, go to game over screen
    private function completeHandler(e:TimerEvent):void
    {
        noReset++;

        if (noReset > 1)
        {
            gotoAndStop(6);
            myText.visible = false;
            overText.text = "Game Over";
        }else{
            nextFrame();
        }
    }

    public function showGameScore()
    {
        showScore.text = String("Score: " + hitscore);
    }

}

[COLOR=Black]
Pardon my messy codes, I’m quite new to as3.[/COLOR]
[COLOR=Black]Thanks and Regards
kup0[/COLOR]

[/COLOR]