Flash错误1010

时间:2013-12-04 18:15:08

标签: flash runtime-error

我正在制造塔防游戏,但我一直在犯这个错误的错误。它告诉我它与事件监听器在同一条线上,它让我发疯,我需要在11月13日之前完成这项工作,请帮忙。有问题的事件监听器是函数onArrowTowerClick中的onEnterFrame

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;

    public class TowerDefence extends MovieClip
    {
        var arrowStop:Boolean;
        var arrowOk:Boolean;
        var i:int = 0;
        var currGold:int;
        var currWave:int;
        var maxWave:int;
        var placings:Array;
        var monsters:Array;
        var towers:Array;
        var bullets:Array;
        var life:int;
        var arrowCheck:Boolean = false;
        var crossCheck:Boolean = false;
        var wizardCheck:Boolean = false;
        var musketCheck:Boolean = false;
    public function TowerDefence():void
    {
        startGame();
    }
    function startGame():void
    {
        currGold = 20000;
        currWave = 0;
        maxWave = 80;
        monsters = new Array();
        towers = new Array();
        bullets = new Array();
        life = 20;
        arrowTowerButton.addEventListener(MouseEvent.CLICK,     onArrowTowerButtonClick);
        arrowTowerButton.addEventListener(MouseEvent.ROLL_OVER, RollOverArrowTowerButtonClick);
        arrowTowerButton.addEventListener(MouseEvent.ROLL_OUT, RollOutArrowTowerButtonClick);
        crossbowTowerButton.addEventListener(MouseEvent.CLICK, onCrossTowerButtonClick);
        crossbowTowerButton.addEventListener(MouseEvent.ROLL_OVER, RollOverCrossTowerButtonClick);
        crossbowTowerButton.addEventListener(MouseEvent.ROLL_OUT, RollOutCrossTowerButtonClick);
        wizardTowerButton.addEventListener(MouseEvent.CLICK, onWizardTowerButtonClick);
        wizardTowerButton.addEventListener(MouseEvent.ROLL_OVER, RollOverWizardTowerButtonClick);
        wizardTowerButton.addEventListener(MouseEvent.ROLL_OUT, RollOutWizardTowerButtonClick);
        musketTowerButton.addEventListener(MouseEvent.CLICK, onMusketTowerButtonClick);
        musketTowerButton.addEventListener(MouseEvent.ROLL_OVER, RollOverMusketTowerButtonClick);
        musketTowerButton.addEventListener(MouseEvent.ROLL_OUT, RollOutMusketTowerButtonClick);
        addEventListener(Event.ENTER_FRAME, onEnterFrame);

    }
    function onArrowTowerClick (event:MouseEvent):void
    {
        if(arrowOk)
        {
            arrowPos();
        }
    }
    function arrowPos():void
    {
        var posxi:int=0;
        var posxii:int=0;
        var posxiii:int;
        var posxiiii:int;
        while(arrowStop == false)
        {
            posxi = posxi + 50;
                if(posxi>(towers[i-1].x+25))
                {
                    posxiii = posxi - (towers[i-1].x+25);
                    posxiiii = towers[i-1].x+25 - posxii;
                    if(posxiii>posxiiii)
                    {
                        towers[i-1].x = posxi;
                        arrowStop = true;
                    }
                    else if(posxiii<posxiiii)
                    {
                        towers[i-1].x = posxii;
                        arrowStop = true;
                    }
                    else if(posxiii==posxiiii)
                    {
                        towers[i-1].x = posxii;
                        arrowStop = true;
                    }
                }
            posxii = posxi;
        }
        var posyi:int=0;
        var posyii:int=0;
        var posyiii:int;
        var posyiiii:int;
        arrowStop = false;
        while(arrowStop == false)
        {
            posyi = posyi + 50;
            if(posyi>(towers[i-1].y-25))
            {
                posyiii = posyi - (towers[i-1].y-25);
                posyiiii = towers[i-1].y-25 - posyii;
                if(posyiii>posyiiii)
                {
                    towers[i-1].y = posyi;
                    arrowStop = true;
                }
                else if(posyiii<posyiiii)
                {
                    towers[i-1].y = posyii;
                    arrowStop = true;
                }
                else if(posyiii==posyiiii)
                {
                    towers[i-1].y = posyii;
                    arrowStop = true;
                }
                if(towers[i-1].y < 200)
                {
                    towers[i-1].y = 200;
                }
            }
            posyii = posyi;
        }
    }
    function onArrowTowerButtonClick(event:MouseEvent):void
    {
        var a:int = 0;
        if(currGold>=10)
        {
            arrowCheck = true;
            currGold-=10;
            towers[i] = new ArrowTower;
            addChild(towers[i]);

            towers[i].gotoAndStop(1);
            i = i + 1;
            arrowStop = false;

        }
    }
    function RollOverArrowTowerButtonClick(event:MouseEvent):void
    {
        cost.text="10";
    }
    function RollOutArrowTowerButtonClick(event:MouseEvent):void
    {
        cost.text="";
    }
    function onCrossTowerButtonClick(event:MouseEvent):void
    {

    }
    function RollOverCrossTowerButtonClick(event:MouseEvent):void
    {
        cost.text="14";
    }
    function RollOutCrossTowerButtonClick(event:MouseEvent):void
    {
        cost.text="";
    }
    function onWizardTowerButtonClick(event:MouseEvent):void
    {

    }
    function RollOverWizardTowerButtonClick(event:MouseEvent):void
    {
        cost.text="40";
    }
    function RollOutWizardTowerButtonClick(event:MouseEvent):void
    {
        cost.text="";
    }
    function onMusketTowerButtonClick(event:MouseEvent):void
    {

    }
    function RollOverMusketTowerButtonClick(event:MouseEvent):void
    {
        cost.text="120";
    }
    function RollOutMusketTowerButtonClick(event:MouseEvent):void
    {
        cost.text="";
    }
    function onEnterFrame (event:Event):void
    {

        totalGold.text = "" + currGold;
        if(arrowCheck)
        {
            if(arrowStop == false)
            {trace(towers);             
                if(towers[i-1].arrowTowerTower.hitTestObject(hitA)||towers[i-1].arrowTowerTower.hitTestObject(hitB)|towers[i-1].arrowTowerTower.hitTestObject(hitC)||towers[i-1].arrowTowerTower.hitTestObject(hitD)||towers[i-1].arrowTowerTower.hitTestObject(hitE))
                    {
                        arrowOk = true;
                        towers[i-1].range.gotoAndStop(1);
                    }
                    else
                    {
                        arrowOk = false;
                        towers[i-1].range.gotoAndStop(2);
                    }
                    if(arrowStop == false)
                    {
                        addEventListener(MouseEvent.MOUSE_OVER,onMousetrack);
                    }
                    else
                    {
                        removeEventListener(MouseEvent.MOUSE_OVER,onMousetrack);
                    }
                    towers.arrowTowerTower.addEventListener(MouseEvent.CLICK,onArrowTowerClick);
                                                            onArrowTowerClick);
            }
        }
    }
    function onMousetrack (event:MouseEvent):void
    {
            towers[i-1].x = event.stageX - 25;
            towers[i-1].y = event.stageY + 25;
    }
}

} enter code here

1 个答案:

答案 0 :(得分:0)

towers.arrowTowerTower.addEventListener(MouseEvent.CLICK,onArrowTowerClick);
                                                            onArrowTowerClick);

应该是

towers.arrowTowerTower.addEventListener(MouseEvent.CLICK,onArrowTowerClick);