Get Adobe Flash player

//FRAME 1 :
stop();

var winner:int;
winner= 0;

stage.addEventListener(MouseEvent.CLICK, StartGame)
function StartGame(evt:Object):void{
gotoAndPlay(2);
trace("winner= " + winner);
}

//FRAME 2 :
///////// KEYBOARD EVENTS ////////////////////
///////////////ship stuff:::::::::::::::::::
starShip.y=300;
var shipSpeed:Number = 20;
var leftBounds:Number = 50;
var rightBounds:Number = 460;

stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
function reportKeyDown(event:KeyboardEvent):void {
var KeyCharCode:uint = event.charCode;

if (KeyCharCode == 97) { // 97 is the keyCode for the "a" key on the keyboard

if (starShip.x > leftBounds) {
starShip.x += -shipSpeed;
}
}

if (KeyCharCode == 100) { // 100 is the keyCode for the "d" key on the keyboard

if (starShip.x < rightBounds) {
starShip.x += +shipSpeed;
}
}
}

///////////////laser stuff:::::::::::::::::::
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown2);
function reportKeyDown2(event:KeyboardEvent):void {
var KeyCharCode2:uint = event.charCode;
if (KeyCharCode2 == 32) { // 32 is the keyCode for the "spacebar" key on the keyboard

laser2.x = starShip.x + 0;
laser2.y = starShip.y - 50;

var laser:Sound = new Sound();
var req:URLRequest = new URLRequest("laser sound.mp3");
laser.load(req);
laser.play();
}
}
gotoAndPlay(3);

 

///////////laser movement:::::::::::::::::::::::
//FRAME 3 :
if(laser2.y<=250){
laser2.y -= 10;
}
if(laser2.y<= -100){
laser2.y = 900;
}
///////EXPLODE/////////
var explode:Sound = new Sound();
var req2:URLRequest = new URLRequest("explode.mp3");

///////////enemy1 movement:::::::::::::::::::::::
if (enemy1.x < 700) {
enemy1.x += 9; // Move the clip over to the new location
}
if (enemy1.x >= 700) {
enemy1.x -= 800;
}
if (enemy2.x < 700) {
enemy2.x += 9; // Move the clip over to the new location //enemy2.x=200;

}
if (enemy2.x >= 700) {
enemy2.x -= 800;
}
if (enemy3.x < 700) {
enemy3.x += 9; // Move the clip over to the new location
}
if (enemy3.x >= 700) {
enemy3.x -= 800;
}
///////////conditions:::::::::::
if(enemy1.y==laser2.y){
if(
(laser2.x>=(enemy1.x-40)) && (laser2.x<=(enemy1.x+40))
){
trace("got it")
trace("winner= " + winner);
explode.load(req2);
explode.play();
winner=winner+1;
enemy1.x = -8000;

}else{
trace("?")
}

}

if(enemy2.y==laser2.y){

if(
(laser2.x>=(enemy2.x-40)) && (laser2.x<=(enemy2.x+40))
){
trace("got it");
trace("winner= " + winner);
explode.load(req2);
explode.play();
winner=winner+1;
enemy2.x = -8000;

}else{
trace("?")
}

}
if(enemy3.y==laser2.y){

if(
(laser2.x>=(enemy3.x-40)) && (laser2.x<=(enemy3.x+40))
){
trace("got it")
trace("winner= " + winner);
explode.load(req2);
explode.play();
winner=winner+1;
enemy3.x = -8000;

}else{
//trace("?")
}
}

if(winner==3){
trace("winner= " + winner);
gotoAndPlay(10)
}