为什么我的按钮不起作用?

时间:2014-12-04 07:07:02

标签: flash-cc

我在这里有一种特殊的情况,通常我对此没有任何问题。

情况是这样的,我有4个屏幕。游戏画面,菜单和获胜屏幕以及死亡屏幕。

情况是允许我的播放器从获胜屏幕进入菜单的按钮不起作用。我跟踪它,按钮正在工作,它只是不移动框架。

这是我使用的代码。

    public function prototype() {

    }
    public function startMenu() {
        btnStart.addEventListener(MouseEvent.CLICK, gotoGame);
    }
    public function gotoGame(evt: MouseEvent): void {
        btnStart.removeEventListener(MouseEvent.CLICK, gotoGame);
        gotoAndStop("game1");
    }
    public function gotoGameA(evt: MouseEvent): void {
        btnContinue.removeEventListener(MouseEvent.CLICK, gotoGameA);
        btnMenu.removeEventListener(MouseEvent.CLICK, gotoFront);
        gotoAndStop("game1");
    }
    public function gotoWin() {
        gotoAndStop("win");
        startWin()
    }
    public function startWin() {
        btnContinue.addEventListener(MouseEvent.CLICK, gotoGameA);
        btnMenu.addEventListener(MouseEvent.CLICK, gotoFront);
    }
    public function gotoFront(evt: MouseEvent): void {
        trace("please work")
        gotoAndStop("menu");
        startMenu();
    }
    public function gotoDeath() {
        gotoAndPlay("death");
    }

我不知道该如何处理。

时间轴:

enter image description here

1 个答案:

答案 0 :(得分:0)

public function startMenu() {
            btnStart.addEventListener(MouseEvent.CLICK, gotoGame);
        }

        private function gotoGame(evt: MouseEvent) {
            btnStart.removeEventListener(MouseEvent.CLICK, gotoGame);
            gotoAndStop("game1");
        }
        private function gotoGameA(evt: MouseEvent) {
            btnContinue.removeEventListener(MouseEvent.CLICK, gotoGame);
            btnMenuA.removeEventListener(MouseEvent.CLICK, gotoMenu);
            gotoAndStop("game1");
        }
        public function startGameWin() {
            btnMenuA.addEventListener(MouseEvent.CLICK, gotoMenu);
            btnContinue.addEventListener(MouseEvent.CLICK, gotoGameA);
        }

        public function startGameOver() {
            btnMenuB.addEventListener(MouseEvent.CLICK, gotoMenuA);
        }

        private function gotoMenu(evt: MouseEvent) {
            trace("hit")
            btnMenuA.removeEventListener(MouseEvent.CLICK, gotoMenu);
            btnContinue.removeEventListener(MouseEvent.CLICK, gotoGame);
            gotoAndStop("game1");
            gotoAndStop("menu");
        }
        private function gotoMenuA(evt: MouseEvent) {
            trace("hit")
            btnMenuB.removeEventListener(MouseEvent.CLICK, gotoMenuA);
            gotoAndStop("game1");
            gotoAndStop("menu");
        }
相关问题