Reputation: 1
I have a perculiar situation here, usually I have no problems with this.
The situation is like this, I have 4 screens. A game screen, a menu and a win screen and a death screen.
the situation is that the buttons that allow my player to go from the win screen to the menu is not working. I traced it and the button is working, it just doesn't move the frames.
here are the codes I used.
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");
}
I am not sure what to do with this.
Timeline:
Upvotes: 0
Views: 287
Reputation: 1
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");
}
Upvotes: 0