4フレームのシーンがあります。最初のフレームには2つのボタンとがInstructions
ありStart
ます。Instructions
指示があるフレーム4にStart
私を導き、ゲームがあるフレーム2に私を導きます。ゲームが終了すると、フレーム3に移動します。ここには、メインメニューを示すボタンがあり、メインメニューにリダイレクトされます。ただし、メインメニューボタンが機能せずError #1009
、タイトルに記載されているとおりになります。AS3を使用するのはこれが初めてなので、愚かさを前もってお詫びします。コードは次のとおりです。
public function projectFinal()
{
startBtn.addEventListener(MouseEvent.CLICK, startGame);
instructionBtn.addEventListener(MouseEvent.CLICK, instructions);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyboardDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyboardUp);
specialTimer.addEventListener(TimerEvent.TIMER, spawnBonus);
monsterTimer.addEventListener(TimerEvent.TIMER, moveMonsters);
mainBtn.addEventListener(MouseEvent.CLICK, endGame);
backBtn.addEventListener(MouseEvent.CLICK, goBack);
}
function startGame(event:MouseEvent):void
{
gotoAndPlay(2);
gameStarted = true;
specialTimer.start();
monsterTimer.start();
spaceShip.score = 0;
//createMonsterRow(monsterRow);
}
function instructions(event:MouseEvent):void
{
gotoAndPlay(4);
trace ("pressed ins");
}
function endGame(event:MouseEvent):void
{
gotoAndPlay(1);
trace("pressed main");
}
function goBack(event:MouseEvent):void
{
gotoAndPlay(1);
}