Skip to main content
October 4, 2007
Question

unloading a movie clip from a for statement

  • October 4, 2007
  • 1 reply
  • 180 views
Hi,

I have this code:

//create empty movie clips to place bin top, flame and bin bottom in that order
this.createEmptyMovieClip("holder_mc2",this.getNextHighestDepth());
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth());
this.createEmptyMovieClip("holder_mc1",this.getNextHighestDepth());

//attach movie clip/variables
var dsfInstance:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 1, 10, 10);
var b:MovieClip = holder_mc2.attachMovie("binTop_mc","binTop_mc",holder_mc2.getNextHighestDepth());
var a:MovieClip = holder_mc1.attachMovie("binBottom_mc","binBottom_mc",holder_mc1.getNextHighestDepth());

//property values

a._x = 419;
a._y = 244;
a._width = 112.0
a._height = 140.0
b._x = 419;
b._y = 175;
b._width = 112.8;
b._height = 10.1;
a.filters = [dsfInstance];

//create for loop to place the flame particle on the stage many times
for(i=0;i<200;i++){
//places in temporary movieclip t
var t:MovieClip = holder_mc.attachMovie("flame","flame"+i,holder_mc.getNextHighestDepth());
// position the movieclip on the stage for y co-ordinates
t._y = 190;
t._x = Math.random()*80+(Stage.width/2+115);

//give the flame random sizes no larger than 80 pixels and no smaller than 20
t._xscale = t._yscale = Math.random()*80 + 20;
//randomize the frame the movieclip is going to start in the flame movie clip is 16 frame long so it will pick number between that
//because math.random produces decimal values we round the number using math.ceil to the high whole number
t.gotoAndPlay(Math.ceil(Math.random()*16));
}

what i want to do is remove the movieclip in the for loop off the stage when i click on a button. i can manage to remove the movie clips with the variables a and b but i cant do it with the one in the for loop.

i put this code in the button:

on(release){
play();
stopAllSounds();
a.removeMovieClip();
b.removeMovieClip();
t.removeMovieClip();
}

Is there a way to do this?
This topic has been closed for replies.

1 reply

Participant
October 4, 2007
im so dumb! i figured it out.

i used the "holder_mc" the name of the empty movie clip.

holder_mc.removeMovieClip();