-
[HELP]removing duplicated movie clip
Basically, a random amount of movieclips have been attached to the stage using attachMovieClip().
how do i remove one of these movieclips from the stage?
I tried this["rock"+b].removeMovieClip()
but that didn't work
PLEASE HELP!
-Matt
Here's the Code (assume there are five movie clips in the library:rockone, rocktwo, rockthree, rockfour, rockfive):
Code:
gridheight = 15;
gridwidth = 15;
gridx=0;
gridy=30;
gridsize = 30;
b = 0;
for (a = 0; a != (gridheight*gridwidth); a++) {
randomnum = random(10);
if (randomnum == 1){
attachMovie("rockone", "rock"+b, b+100);
} else if (randomnum == 2){
attachMovie("rocktwo", "rock"+b, b+100);
} else if (randomnum == 3){
attachMovie("rockthree", "rock"+b, b+100);
} else if (randomnum == 4){
attachMovie("rockfour", "rock"+b, b+100);
} else if (randomnum == 5){
attachMovie("rockfive", "rock"+b, b+100);
}
if (randomnum>0 && randomnum<6){
this["rock"+b]._x = ((a % gridwidth)*gridsize)+gridx;
this["rock"+b]._y = ((Math.floor(a/gridwidth))*gridsize)+gridy;
b=b+1;
this["rock"+b].removeMovieClip();
}
}
goldystudios.com - still under construction
-
Registered User
hi,
Your code doesn't work because:
- you attach a movie clip, and call it "rock"+b
- you increase the b: b=b+1
- you try to remove "rock"+b which doesn't exist yet because you increased b
i.e.,
if b=4,
- you have rock4 (you attached it)
- b=5 (you increased b)
- you try to remove rock5 (rock5 doesn't exist yet)
Last edited by nunomira; 03-25-2004 at 09:29 PM.
-
wow, i feel really dumb right now
Thanks very much, can't believe i missed that!
goldystudios.com - still under construction
-
Registered User
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|