//**************VARIABLES**************/
var
gameState:String;
This creates a string
variable (Like an envelope) which is adding a variable called gamestate which
is for characters.
//*********BEGINNING
STUFF**************/
endScreen.visible
= false;
This make the end
screen not visible
//**************INTRO
SCREEN**************/
introScreen.play_btn.addEventListener
(MouseEvent.CLICK, clickAway); Intro screen is a movie clip with the child play_btn that has a
function inside it called EventListener that waits for the mouse click.
function
clickAway (event:MouseEvent):void { This makes a function
named clickaway which is a mouse event once you click on that, it activates
movescreenoff which takes the intro screen off the page but the name
movescreenoff could be called anything
moveScreenOff (introScreen); - calls a function
called moveScreenoff
}
function
moveScreenOff (screen:MovieClip):void { This mean the function above is now void once clicked. Which means
that the function after clicked will no longer go back to the same.
screen.x = (screen.width)*-1; The screen is moved
away I the x axis
gameState = "INITGAME"; This is the value of gamestate
addEventListener (Event.ENTER_FRAME,
gameLoop); This triggers the enterframe event which when triggered it
activates gameLoop
}
//**************STATE_INIT_GAME**************/
function initGame ():void {
The function initgame is being taken away by being void.
trace("add stuff to
initGame") This allows the value initgame to show
gameState
= "STARTPLAYER"; The variable gamestate now remembers the word STARTPLAYER.
//**************STATE_START_PLAYER**************/
function
startPlayer ():void {
trace("add
player stuff")
gameState = "PLAYGAME"; The
variable gamestate now remembers the word PLAYGAME
//**************STATE_PLAY_GAME**************/
function
playGame ():void { This creates the function playeGame
makeEnemies (); Calls the function
maleenemies
testForEnd (); calls the function
testForEnd
}
function
makeEnemies ():void { Flash will not return these values by default
}
function testForEnd ():void { Flash will not return these
values by default
gameState
= "ENDGAME"; Makes gamestate variable to rememeber ENDGAME.
}
//**************STATE
ENDGAME**************/
function
endGame ():void { This creates the function endGame
removeGame ();
endScreen.visible = true;
removeEventListener (Event.ENTER_FRAME,
gameLoop);
showResults ();
}
function
showResults ():void {
trace ("Show Results");
endScreen.play_btn.addEventListener
(MouseEvent.CLICK, clickFinalAway);
function clickFinalAway
(event:MouseEvent):void {
trace ("clickFinalAway");
moveScreenOff (endScreen);
}
}
//**************REMOVE
GAME**************/
function
removeGame ():void {
}
