# When last movieClip removed

I have some code that I found at Senocular.com that I am trying to figure out. I am trying to find out when the last movieClip or few movieClips have been removed. I need to fade in some text when the last clip is gone. The code creates a grid of squares and fades them out randomly.

Appreciate any help.:sen:

``````
stop();
//depth of the text is determined by the number of squares; square.getDepth()
//if you don't swap depths the text is hidden
text_mc._alpha = 0;
text_mc.swapDepths(1500);
var cols = 74;// columns of fading squares
var rows = 20;// rows of fading squares
// ^ these are based on your square's width and the area it has to cover
var speed = 5;// speed of fade
// once a timeout variable reaches 0
if (this.timeout-- <= 0){
// fade until 0 alpha then remove;
if ((this._alpha -= speed) <= 0) {
this.removeMovieClip();
}

}
};
// CreateSquares: creates the squares over an area starting at x, y
// and based on cols, rows that fade out based on Fader
CreateSquares = function (x, y, rows, cols) {
// variables; r and c count rows and columns
var r, c, square;
var depth = 0;
var initx = x;
// initial x position
for (r=0; r<rows; r++) {
for (c=0; c<cols; c++) {
// create each square for each row and column
square = this.attachMovie("whitesquare", "square"+depth, depth, {_x:x, _y:y});
if (r>=0 && r<=20 && c>=0 && c<=30) {
square.timeout = Math.floor(Math.random()*50);
}
if (r>=0 && r<=20 && c>=31 && c<=40) {
square.timeout = Math.floor(Math.random()*100);
}
if (r>=0 && r<=20 && c>=41 && c<=74) {
square.timeout = Math.floor(Math.random()*180);
}
/**/
// Fader as onEnterFrame event function
depth++;
x += square._width;
// set next position for next square
trace(square.getDepth());

}
x = initx;
// return x back to the left of the square grid
y += square._height;
// increase y for next row

}
};
// create the squares to begin the effect
// content is the movieclip holding the image to
// be revealed in this manner
CreateSquares(content._x,content._y,rows,cols);

``````