# It won't gotoAndPlay! boo hoo!

**URL:** https://forum.kirupa.com/t/it-wont-gotoandplay-boo-hoo/65445
**Category:** Uncategorized
**Created:** [September 26, 2004, 2:15pm UTC](https://forum.kirupa.com/t/it-wont-gotoandplay-boo-hoo/65445 "2004-09-26T14:15:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mcpalmer](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mcpalmer](https://forum.kirupa.com/u/mcpalmer)
#### Post date: [September 26, 2004, 2:15pm UTC](https://forum.kirupa.com/t/it-wont-gotoandplay-boo-hoo/65445/1 "2004-09-26T14:15:06Z")

</div>

I got a problem with this game i’ve made. The main has got 3 frames - first shows a title screen , second the game and third an end screen. From the endscreen iwant to restart game or go back to the title screen. The restart button works fine but if i want to go back to the title screen, the button doesn’t work - the title screen will show v briefly then disappear. There is a lot of code here but here is the main stuff:

first frame: starts game

Has play button with this script:

on(release){  
Display.clearResults();  
\_root.gotoAndPlay(2)  
}

2nd frame: game

Intitlaizes all da vars and inits game and starts it with this code:

stop();  
// attach Ship  
attachMovie(“saucer”, “myShip”, 50);  
myShip.\_x = 50;  
myShip.\_y = 50;  
var enA = new Array(4);  
var bulletA = new Array(5);  
var bombA = new Array(5);  
var enBullA = new Array(7);

for (var i =0;i\<5;i++){  
attachMovie(“laser\_mc”, “laser”+i, 100+i);  
bulletA\* = \_root[“laser”+i];  
}  
for(var i=0;i\<5;i++){  
attachMovie(“bomb\_mc”,“bomb”+i,300+i);  
bombA\* = \_root[“bomb”+i];  
}  
// -------- ATTACH ENEMY ARRAY -------------  
for (var j = 0; j\<4; j++) {

if(j\<3){//attach enemyships  
attachMovie(“enemy1”, “en\_ship”+j, 500+j);  
enA[j] = \_root[“en\_ship”+j];  
} else {  
//attach enemytanks  
attachMovie(“en\_tank”, “en\_tank”+j, 500+j);  
enA[j] = \_root[“en\_tank”+j];  
}  
}  
// ==== attach enemy bullet array =====  
for (var i = 0; i\<7; i++) {  
attachMovie(“en\_bullet2”, “bullet”+i, 700+i);  
enBullA\* = \_root[“bullet”+i];  
}  
var myGame = new Game(myShip, enA, bulletA, bombA, enBullA);  
// ======= Key capture ============ //  
laserListener = new Object();  
laserListener.onKeyDown = function() {  
myGame.fireLaser();  
};  
bombListener = new Object();  
bombListener.onKeyDown = function() {  
myGame.fireBomb();  
};  
Key.addListener(laserListener);  
Key.addListener(bombListener);  
// initialise game  
myGame.initGame();  
Sounds.siren.start();  
// game loop  
\_root.onEnterFrame = function() {  
myGame.startGame();

};

A method in the Game class checks if all lives are lost - if so the game ends and we gotoandStop(3):

has a restart button and titlescreen button:

restart works thusly:

on(release){  
Display.clearResults()  
\_root.gotoAndStop(2)  
}

titlescreen does \<\<\<not\>\>\>\> work thusly:

on(release){  
Display.clearText();  
\_root.gotoAndStop(1);  
}

Like i said. it flicks to the title screen very quickly and then back again. I’m not sure if the code i given will help solve the problem but i hope so. It seems like either a bug in Flash (i doubt it) or user error. The latter is much more likely:) There must be another instance where this sort of thing has happened to someone else here?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 26, 2004, 2:24pm UTC](https://forum.kirupa.com/t/it-wont-gotoandplay-boo-hoo/65445/2 "2004-09-26T14:24:17Z")

</div>

coudl you post the fla so it’s more obvious what all that’s doing?
