我在as3中遇到堆栈溢出错误

时间:2012-11-14 06:06:49

标签: actionscript-3

我是flash的初学者,但不是面向对象的程序。 我做了一个商业模拟多人桌面游戏。这个敬礼功能是从一个.fla文件调用的,这个敬礼函数调用moveto function.the 敬礼功能正常工作。但问题来自 moveto() dialog2.x = 200; 。如果删除该行问题转到下一行,请帮助我

 public function salute(a:Array)
{
    a[0].x=200;
    a[0].y=200;
    if(k==0)
    {
    tilehold.amount.text=String(amount);
    tilehold.networth.text=String(networth);
    tilehold.playertitle.text=playername;
    dialog2=a[1];
    dialog3=a[2];
    dialog4=a[3];
    dialog5=a[4];
    dialog6=a[5];
    forbuild=a[6];
    k=1
    }
    a[0].dialogtext.text=playername+"'s turn";
    a[0].addEventListener(MouseEvent.MOUSE_DOWN,nothing1);
    function nothing1(e:MouseEvent)
    {
        a[0].x=1000;
        e.target.removeEventListener(MouseEvent.MOUSE_DOWN,nothing1);
        a[7].x=-10;
        a[7].y=-10;
        a[7].addEventListener(MouseEvent.CLICK,wheelspin);
    }
    function wheelspin(e:MouseEvent)
    {
        spinvalue=Math.floor(Math.random()*10);
        a[7].wheel.spin(spinvalue);
        a[7].wheel.gotoAndPlay(2);
        e.target.removeEventListener(MouseEvent.CLICK,wheelspin);
        a[7].addEventListener(MouseEvent.CLICK,wheelmove);
    }
    function wheelmove(e:MouseEvent)
    {
        a[7].x=1000;
        e.target.addEventListener(MouseEvent.CLICK,wheelmove);

    }
    moveto();
}
public function moveto()
{
    if(spinvalue==0||spinvalue==7||spinvalue==8||spinvalue==9)
    {
        if(nooflandsown==0)
        {
  

/ *上面的一个工作正常但是,这个错误表明行* /

                            dialog2.x=200;
            dialog2.dialogtext.text="you dont own any land";
            dialog2.okbut.addEventListener(MouseEvent.CLICK,nothing2);
            function nothing2(e:MouseEvent)
            {
                dialog2.x=1000;
                e.target.removeEventListener(MouseEvent.CLICK,nothing2);
                endturn();
            }

        }
        else
        {
            dialog3.x=200;
            dialog3.y=200;
            dialog3.dialogtext.text="do you want to build";
            dialog3.yesbut.addEventListener(MouseEvent.CLICK,wanttobuild);
            dialog3.nobut.addEventListener(MouseEvent.CLICK,nothing3);
            function wanttobuild(e:MouseEvent)
            {
            dialog3.x=1000;
            e.target.removeEventListener(MouseEvent.CLICK,wanttobuild);
            dialog3.nobut.removeEventListener(MouseEvent.CLICK,nothing3);
             chooseland();
            }
            function nothing3(e:MouseEvent)
            {
                dialog3.x=1000;
                dialog3.yesbut.removeEventListener(MouseEvent.CLICK,wanttobuild);
            e.target.removeEventListener(MouseEvent.CLICK,nothing3);
            endturn();
            }
        }
    }
    else
    {
        l=(currentposition+spinvalue)%18;
        this.pos=l;
        switch(currentposition)
        {
            case 1:
            this.gotoAndPlay(15);
            break;
            case 2:
            this.gotoAndPlay(25);
            break;
            case 3:
            this.gotoAndPlay(35);
            break;
            case 4:
            this.gotoAndPlay(55);
            break;
            case 5:
            this.gotoAndPlay(65);
            break;
            case 6:
            this.gotoAndPlay(75);
            break;
            case 7:
            this.gotoAndPlay(85);
            break;
            case 8:
            this.gotoAndPlay(105);
            break;
            case 9:
            this.gotoAndPlay(115);
            break;
            case 10:
            this.gotoAndPlay(125);
            break;
            case 11:
            this.gotoAndPlay(135);
            break;
            case 12:
            this.gotoAndPlay(145);
            break;
            case 13:
            this.gotoAndPlay(165);
            break;
            case 14:
            this.gotoAndPlay(175);
            break;
            case 15:
            this.gotoAndPlay(195);
            break;
            case 16:
            this.gotoAndPlay(205);
            break;
            case 17:
            this.gotoAndPlay(215);
            break;
            default:
            this.gotoAndPlay(1);
        }
        currentposition=l;


    }
}

请帮帮我。我通过改变整个代码尝试了很多。但我无法弄清楚

1 个答案:

答案 0 :(得分:0)

首先,为什么在事件监听器(函数wheelmove)中添加事件监听器?其次,检查您是否实际退出moveto()函数而不再调用salute(),如果不是,则必须在其他地方更改代码流逻辑。此外,如果代码较大,您可以使用Internet中的PasteBin服务来托管代码。