I am trying to assign buttons my on my ‘gameScreen’ to move my character. though I am receiving an error msg saying: Error #1010: A term is undefined and has no properties.
at Mainas()
Could somebody please help me out on this matter.
Thank you.
package{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Mainas extends MovieClip{
var instructions:InstructionsPage;
var gameScreen:GameScreen;
var endGameScreen:EndGameScreen;
var sc:Scuba
public function Mainas(){
instructions = new InstructionsPage();
gameScreen = new GameScreen();
endGameScreen = new EndGameScreen();
sc = new Scuba
instructions.playBtn.addEventListener(MouseEvent.CLICK,gotoGame);
gameScreen.endgameBtn.addEventListener(MouseEvent.CLICK,endGame);
endGameScreen.playagainBtn.addEventListener(MouseEvent.CLICK,playAgain);
gameScreen.upBtn.addEventListener(MouseEvent.CLICK,moveUp)
gameScreen.downBtn.addEventListener(MouseEvent.CLICK,moveDown);
gameScreen.leftBtn.addEventListener(MouseEvent.CLICK,moveLeft);
gameScreen.rightBtn.addEventListener(MouseEvent.CLICK,moveRight);
gameScreen.rotateBtn.addEventListener(MouseEvent.CLICK,rotate);
gameScreen.biggerBtn.addEventListener(MouseEvent.CLICK,makeBigger);
gameScreen.smallerBtn.addEventListener(MouseEvent.CLICK,makeSmaller);
gameScreen.visibleBtn.addEventListener(MouseEvent.CLICK,makeInvisible);
init();
addChild(instructions);
}
private function gotoGame(evt:MouseEvent):void{
removeChild(instructions);
addChild(gameScreen);
sc.x = 320;
sc.y = 300;
addChild(sc);
}
private function endGame(evt:MouseEvent):void{
removeChild(gameScreen);
addChild(endGameScreen);
}
private function playAgain(evt:MouseEvent):void{
removeChild(endGameScreen);
addChild(instructions);
}
private function moveUp(event:MouseEvent):void{
sc.y -= 10;
}
private function moveDown(event:MouseEvent):void{
sc.y += 10;
}
private function moveLeft(event:MouseEvent):void{
sc.x -= 10;
}
private function moveRight(event:MouseEvent):void{
sc.x += 10;
}
private function rotate(event:MouseEvent):void{
sc.rotation += 10;
}
private function makeBigger(event:MouseEvent):void{
sc.scaleX = sc.scaleY += 0.1;
}
private function makeSmaller(event:MouseEvent):void{
sc.scaleX = sc.scaleY -= 0.1;
}
private function makeInvisible(event:MouseEvent):void{
sc.visible=false;
}
}
}