Forum Topic: deleting multiple duplicated MC's

(87 views • 1 reply)

This topic is 1 page long.

<< < > >>
Resigned

farfenwaffle

Reply To Post Reply & Quote

Posted at: 5/6/09 12:08 AM

farfenwaffle LIGHT LEVEL 16

Sign-Up: 06/07/07

Posts: 1,941

Hey, I'm not a coder but i thought it would be fun to try to make a little side scrolling shooter.
I used thsi code tobring my little basterd enemys into the world:

for (i = 1; i < nrEnemies; i++)
{
	_root.Enemy0.duplicateMovieClip("Enemy" + i, _root.getNextHighestDepth());
}

now that little chunk of code was the only bit i got from the internet, Now I am regretting not knowing the code!
I just can't understand it. now when I go to the next frame the enemys are still there floating around,
heres what i need:
-whats the proper use for: _root.[movieclip].deleteMovieClip to make all of the spawned enemys go away?
-what the heck does my code mean?
-should I ever do something stupid like this ever again?

Join?

BBS Signature

None

Denvish

Reply To Post Reply & Quote

Posted at: 5/6/09 02:28 AM

Denvish DARK LEVEL 45

Sign-Up: 04/25/03

Posts: 16,238

At 5/6/09 12:08 AM, farfenwaffle wrote: -whats the proper use for: _root.[movieclip].deleteMovieClip to make all of the spawned enemys go away?
for (i = 1; i<nrEnemies; i++){
	_root["Enemy" + i].removeMovieClip();
}
-what the heck does my code mean?

This is a FOR loop that runs repeatedly.

It will start looping from the point where i (a counter) =1.

for (i = 1;

It will stop looping when i stops being less than max number of enemies (variable: nrEnemies).

i<nrEnemies;

Every loop, i will be incremented by one

i++){

Everything that's inside the curly brackets is the code that will be executed each loop - in the case of your code, it duplicates a new enemy on each loop.

for (i = 1; i<nrEnemies; i++){
//DO STUFF
}
-should I ever do something stupid like this ever again?

You should check out the Flash help files (press F1 in Flash) and maybe AS: Main if you're keen on learning how to code games.

- - Flash - Music - Images - -

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 04:21 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!