PDA

View Full Version : Duplicating movie clip problem



Zak
March 18th, 2004, 06:08 PM
onClipEvent (enterFrame) {
if(Key.isDown(Key.RIGHT)){
this._x += 5;
}
else if(Key.isDown(Key.LEFT)){
this._x -= 5;
}
else if(Key.isDown(Key.SPACE)){
_root.fire = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, "bullet"+_root.i, _root.i);
}
}


This won't duplicate the movie clip bullet, (instance name bullet) anyone have any ideas, its for a shooting game, and it just erases the 1st bullet and makes a new one.

Zak
March 19th, 2004, 11:03 AM
OK, no one answer thats cool!

Voetsjoeba
March 19th, 2004, 03:03 PM
I'm sure you'll find the solution.

bombsledder
March 21st, 2004, 01:04 PM
how about "bullet2" instead of "bullet"

Zak
March 21st, 2004, 02:49 PM
nope i duno i cant fire for some reason, :(

flash4food
March 21st, 2004, 03:14 PM
post the fla with the problem so i can take a look

Zak
March 21st, 2004, 03:53 PM
ok i will here it is. Thanks alot, it seems simple and i remember doing stuff like this before but now its messed up. thanks though :)

flash4food
March 21st, 2004, 04:21 PM
either theres something wrong with the file, or its flash mx 2004 cuz i couldnt open it and i have flash mx

Zak
March 21st, 2004, 04:24 PM
ok i will upload the mx version

Zak
March 21st, 2004, 04:25 PM
here it is

flash4food
March 21st, 2004, 04:32 PM
what the..? still cant open it...

Zak
March 21st, 2004, 04:46 PM
There is a movie clip (instance name "crab") with these actions.

onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += 5;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 5;
} else if (Key.isDown(Key.SPACE)) {
_root.fire = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, "bullet"+i, i);
}
}

And then the (instace name "bullet) thing it fires has these actions.

onClipEvent (load) {
this._visible = 0;
if (_root.fire == 1) {
this._x = _root.crab._x;
this._y = _root.crab._y;
}
}
onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if (_root.fire == 1) {
this._y -= 5;
this._visible = 1;
}
if (this._y<0) {
this.removeMovieClip();
}
}
}

REEFˇ
March 21st, 2004, 08:11 PM
Originally posted by bombsledder
how about "bullet2" instead of "bullet" This will cause the code to duplicate the bullet only once :).

flash4food
March 22nd, 2004, 09:15 PM
like i said before (on ur other thread i think)

u have to replace

duplicateMovieClip(_root.bullet, "bullet"+i, i);

with:

duplicateMovieClip(_root.bullet, "bullet"+_root.i, _root.i);

and that works!!! dont know why didnt u listen tome before

bombsledder
March 23rd, 2004, 06:23 PM
yea now that i think of it it would do that. my bad

Zak
March 23rd, 2004, 07:40 PM
Doesnt work , sorry guys! maybe try it out for yourselfs it would only take a few seconds to make.