PDA

View Full Version : RemoveMovieClip trouble


vicci
05-18-2004, 04:42 AM
Hi all !

I have a small trouble with a removeMovieClip function:
Iam trying to remove attached MC by clicking on a button but it dont function. The MC are attached dynamiqly thanks to xml and they are attached to an other Mc. I have tried with SwapDepth but nothing better.

here the as to attached my mc:


noeuds = this.firstChild.childNodes;
for (var i = 0; i<noeuds.length; i++) {
link = _root.MC1.MC2.attachMovie(noeuds[i].attributes.ico, "test"+i, i);
link.ico = noeuds[i].attributes.ico;

"link" is a variable which unable me to set property to the mc attached.
"_root.MC1.MC2" its the MC which i attach my other mcs ""test"+i" ;

here the as to remove my mc:
on (press) {
unloadMovie(_root.MC1.MC2["test"+i]);
}


Any idea ? Thx a lot

tg
05-18-2004, 04:55 PM
try:
on(press){
_root.MC1.MC2["test"+i].removeMovieClip();
}

but there is a 'gotcha' with this code, unless you're tracking 'i' somewhere else, 'i' will of course have the value of noeuds.length, so flash won't find the correct movieclip to remove.

vicci
05-21-2004, 05:23 AM
thx tj for the answer.
I have find the solution, i have just forgotten to put my loop:

So the good as is :

on(press){
for (var=i;i<noeuds.length;i++){
removeMovieClip(_root.MC_1.MC2["test"+i];
}