-2

我是 Flash 初学者,但不是面向对象编程的初学者。我正在制作一个商业模拟多人棋盘游戏。这个敬礼函数是从 .fla 文件调用的,这个敬礼函数调用 moveto 函数。敬礼函数工作正常。但是问题出现在dialog2.x=200处的moveto() ;.如果我删除该行问题转到下一行请帮助我

 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;


    }
}

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

4

1 回答 1

0

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

于 2012-11-14T06:55:57.830 回答