Yllier
1122 posts
|
I was working on a game and when I tried to duplicate 2 movie clips only one worked.
for(f=1;f<=5;f++)
{
_root["red"].duplicateMovieClip("red"+f,f+1000,face);
}
for(i=1;i<=5;i++)
{
_root["green"].duplicateMovieClip("green"+i,i+1000,face);
}
Thats the code I used. I had it and only one worked.It was the red one that worked. When i took out the red one and tried the same thing with green, it didn’t work. The code i had on the movie clips were
Red:onClipEvent (load) {
function reset() {
if (this._name == "green") {
this._visible = false;
} else {
this._visible = true;
}
this.dead = 0;
this.speed = random(5)+3;
this._y = 700;
this._x = random(540);
}
this.reset();
}
onClipEvent (enterFrame) {
this._y -= this.speed;
if (this._y<-40) {
this.reset();
}
}
and onClipEvent (load) {
function reset() {
if (this._name == "red") {
this._visible = false;
} else {
this._visible = true;
}
this.dead = 0;
this.speed = random(5)+3;
this._y = 700;
this._x = random(540);
}
this.reset();
}
onClipEvent (enterFrame) {
this._y -= this.speed;
if (this._y<-40) {
this.reset();
}
}
If anyone can tell me why the green one won’t work I’d be happy.
|
Moonkey
1007 posts
|
It looks like you’re using the same range of depth values for duplicating your reds and greens (1001 to 1005), which means the greens are plastering over and removing the reds that were in those depth slots previously.
|
Kalinium
764 posts
|
I think he’s putting them all onto the same depth (face?). If you’re not worried about controlling the depths overly, you can use getNextHighestDepth() to place it onto the next available depth.
Also, when posting code, try to put it onto lots of lines. That’s really hard to read.
|
Yllier
1122 posts
|
Yeah, I dunno why its so messy. Thanks guys
|