I am a tyro who's operative for months on a diversion and now I've got
stranded on a problem.I am new to actionscript 3 though i learn fast.I can
bucket my menu shade ("startScreen.swf") into my diversion (firstgame)
automatically and all works glorious when we click play or storyScreen or
instructionsScreen. But a problem is that we wish to relapse after dire
ESC button. we have attempted many formula though zero works accurately
how we want. Example: we click on story and a swf (storyScreen.swf) loads
and we can review a story and when we am finished, we wish to press ESC to
reload my swf (startScreen.swf) and all a functions in it. Like play and
instructions. You can find my formula and lifeless space in a duty (esc).
we know it is maybe easy to solve though we unequivocally don't know how.
:(public category FirstGame extends MovieClip{ open var
Player:MovieClip private var leftKeyIsDown:Boolean; private var
RightKeyIsDown:Boolean; private var aMissileArray:Array; private var
aEnemyArray:Array; open var scoreTxt:TextField; open var
ammoTxt:TextField; open var MenuEnd:EndGameScreen; open var
menuAgain:EndGameScreen; private var MenuStart:mcStartGameScreen;
private var MenuStory:mcStartGameScreen; private var
MenuInstructions:mcStartGameScreen; private var nScore:Number;
private var nAmmo:Number; private var tEnemyTimer:Timer; open duty
FirstGame() { //Create a loader vigilant var
startLoader:Loader = new Loader(); //add eventuality listener to
listen for a finish eventuality
startLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
startLoaded); //load the loader vigilant
startLoader.load(new URLRequest("startScreen.swf")); } open duty
startLoaded(e:Event):void { MenuEnd.hideScreen();
Player.visible = false; scoreTxt.visible = false;
ammoTxt.visible = false; //get a anxiety to a hallowed movieclip
MenuStart = e.target.content as mcStartGameScreen; //listen for
start diversion eventuality
MenuStart.addEventListener("START_GAME", playGameAgain); //add it
to a theatre addChild(MenuStart); //get a anxiety to a
hallowed movieclip MenuStory = e.target.content as
mcStartGameScreen; //listen for start diversion eventuality
MenuStory.addEventListener("SHOW_STORY", storyGameScreen); //add it
to a theatre addChild(MenuStory); //get a anxiety to a
hallowed movieclip MenuInstructions = e.target.content as
mcStartGameScreen; //listen for start diversion eventuality
MenuInstructions.addEventListener("SHOW_INSTRUCTIONS",
instructionsGameScreen); //add it to a theatre
addChild(MenuInstructions); } private duty
instructionsGameScreen(e:Event):void { var
instructionsLoader:Loader = new Loader(); var url:URLRequest = new
URLRequest("instructionsScreen.swf"); instructionsLoader.load(url);
addChild(instructionsLoader);
stage.addEventListener(KeyboardEvent.KEY_UP, esc); } private duty
storyGameScreen(e:Event):void { var storyLoader:Loader = new
Loader(); var url:URLRequest = new URLRequest("storyScreen.swf");
storyLoader.load(url); addChild(storyLoader);
stage.addEventListener(KeyboardEvent.KEY_UP, esc); } private duty
esc(e:KeyboardEvent):void { if (e.keyCode == 27) {
//fscommand("quit"); /////////test//////////////////(new
URLRequest(stage.loaderInfo.url), "FirstGame.swf"); } }
private duty playGameAgain(e:Event):void { //initialize
variables aMissileArray = new Array(); aEnemyArray = new
Array(); nScore = 0; nAmmo = 20; Player.x = 262,95
Player.y = 323,30 Player.visible = true;
scoreTxt.visible = true; ammoTxt.visible = true;
MenuStart.hideScreen(); MenuEnd.addEventListener("PLAY_AGAIN",
playGameAgain); MenuEnd.hideScreen(); updateScoreText();
updateAmmoText(); //trace("First Game Loaded");
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUp);
stage.addEventListener(Event.ENTER_FRAME, gameLoop) //creat an
timer vigilant tEnemyTimer = new Timer(1000) //listen for a
timer ticks/intervals
tEnemyTimer.addEventListener(TimerEvent.TIMER, addEnemy) //start
the timer tEnemyTimer.start(); }
No comments:
Post a Comment