Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping a function 2

Status
Not open for further replies.

Adam14

Technical User
Nov 8, 2003
193
0
0
CA
Seriously, and sadly, I've been trying to figure this out for over a month now. First of all, this is a flash 5 problem, if there are any more dinosaurs out there who haven't upgraded yet :( I have made a game that consists of two different planes flying across the screen. If there aren't enough of the planes, or if the plane passes a certain y position, the function is called again. If the planes hit the player's plane, the movie moves to frame four. Frame four doesn't have the enemy planes on it, but they still fly. I've tried:
function reset(stop)
after the "if" that contains the hittest for the two planes, but it simply stops the planes flying the after first time around. Below are the links to the page that conatins the game, as is, and also another link to the fla, you'll see that even after the player's plane is hit, the blue planes keep flying....if anyone has an answer, that would be great!!!


And the fla is at:

The blue and red plane are the ones in question, and they consist only in the second and third frame

Thanks,
 
Okay, I fixed your problem by adding a couple of
Code:
if
statements and throwing in a couple of variables, and it worked for me! The .fla is here:


Happy Flashing!
FLASHfreak :)

Oh yeah, sorry about the fonts, they got kinda messed up on my computer :)

FLASHfreak :)
- The Flash Experience
 
I'd have a look to propose my solution, but can't open your .fla. Are you on Mac?
 
Thank you FlashFreak for the fix, but is there any way you can save it in flash 5 so that I can view it, the fla you posted won't open in flash 5. No oldnewbie, I am not using a Mac. As you might have noticed that file had a "u" at the end of it, showing which version I was working on. I can try to upload the "e" version which was from weeks ago but still has the same problem and hopefully you will be able to open this one.


Thanks, Adam
 
Curious! I can open this last one but not the other. Doesn't make sense. Can you upload the first one again?
 
Okay, I don't know how to save for Flash 5 format, so I am just going to give you some instructions that worked for me. First, enter this code on the first frame under the "Control" layer:

Code:
ended = false

Okay, on the second frame, replace your code with this code:

Code:
numEnemy = 5;
if (ended=true) {
	stop();
} else {
	for (i=2; i<=numEnemy; i++) {
		enemy1.duplicateMovieClip(&quot;enemy&quot;+i, i+200000);
	}
	numEnemy2 = 5;
	for (j=2; j<=numEnemy2; j++) {
		enemy2.duplicateMovieClip(&quot;enemytwo&quot;+j, j+200000);
	}
	numlaser = 2;
	for (n=2; n<=numlaser; n++) {
		enemylaserone.duplicateMovieClip(&quot;enemylasersone&quot;+n, n+200000);
	}
	numlaser2 = 2;
	for (z=2; z<=numlaser; z++) {
		enemylasertwo.duplicateMovieClip(&quot;enemylaserstwo&quot;+z, z+200000);
	}
	numlaser3 = 2;
	for (k=2; k<=numlaser3; k++) {
		enemylaserthree.duplicateMovieClip(&quot;enemylasersthree&quot;+k, k+200000);
	}
	numlaser4 = 2;
	for (l=2; l<=numlaser4; l++) {
		enemylaserfour.duplicateMovieClip(&quot;enemylasersfour&quot;+l, l+200000);
	}
}

And on the last frame of that layer, enter this code in:

Code:
ended = true

And there you have it! Hope it works out for you! It seems that the code in the second frame of &quot;Control&quot; kept looping itself.

FLASHfreak :)

FLASHfreak :)
- The Flash Experience
 
Thanks FLASHFreak, I will try that. That was not something I had even thought of. Genius!! And, oldnewbie, I've renamed that first file and uploaded it again here:


That is weird that one would work, and yet, the other wouldn't. Thanks for your time!

Adam
 
Ok, I tried that FLASHFreak, and it worked great. However, now instead of having up to 5 copies of that blue plane flying at one time, I only have one. Any ideas?
 
Any luck downloading that second link, old?
 
Cool, thanks oldnewbie for your time!!! It's just that it's been over a month of trying and changing and trying and changing with no luck that I finally had to harass you geniuses for a solution. Any help you have, as you know, is greatly appreciated.

Adam
 
One question?

Where the hell is this movie ever told to go and stop on frame 4?
 
Oops, this is where I need to get into frame labels. Any hitTest that hit the player's plane had the movie going to Frame 5 - which is where I had it ending before. Weird that it would still jump to frame four, no? I changed them all, but it still didn't help my problem :( You've got a keen eye, Capt'n!
 
Ok! Another question?

Ain't I suppose to see 5 red enemy ships and 5 blue enemy ships, rather than just 1 red ship?

Why depth 200000?
 
Making sure you end up on frame 4, when the game is over... Add this on frame 4:

trace(&quot;YO!&quot;); //Just to see if you do end up on frame 4
for (j=2; j<=numEnemy2; j++) {
_root[&quot;enemytwo&quot;+j].removeMovieClip();
}

Also noted that you sometimes use &quot;score&quot; alone, or &quot;_root.score&quot;, or even &quot;Score&quot; as your textfield's variable names. You should be consistent, and allways use &quot;_root.score&quot;
 
Ok, to answer your first question, yes you should see 5 red planes as well. I got this code from a downloaded fla., and changed it to fit what I needed. I have no idea - maybe you can tell me - why there aren't more red planes. It actually worked out good, so that the red planes would fly faster than the blue ones and the score you accumulated was relavtive to enemy-plane speed. But I have no idea why there is only the one plane, when the blue planes have the exact same code...any ideas? The depth, once again you might have an answer for it. The code I downloaded had it set at 100...but after about thirty seconds or so, the planes stopped duplicating. I thought I would just screw around with numbers - seeing as I'm still extremely learning - and see what happend, and voila! the planes kept on flying. To me it makes no sense, but it fixed the problem. As far as the variable names, I know I should be consistent. This &quot;game&quot; has been trial and error since the get-go...more of a learning tool than anything. That fix you gave me worked PERFECT!!!! The &quot;YO&quot; appeared, and the planes stopped flying. You are the best!!! Sorry I hadn't responded earlier, my father-in-law was over, helping me fix stuff with the house. Thank you so much for your time, and to FLASHFreak as well, if he's still following this thread. If you have any reasons as to the red planes, and why the depth of 200000 works, I'd love to hear you ideas.

Adam
 
Pretty weird, old. I was screwing around with the depth thing again, and changed it to 1, instead of 200000, and the planes were actually disappearing halfway 'cross the screen...it makes no sense to me. Have you got a hypothesus?
 
Thanks again, old. I'll check that out!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top