Make your own free website on Tripod.com

Depths and removeMovieClip
ericlin@ms1.hinet.net


What movieClip can not be removed by this.removeMovieClip() ?

1.

The movieClip instance on the stage that we drag out from library can not be removed by removeMovieClip(). 

The method "removeMovieClip" is to remove movieClip created by "duplicateMovieClip", "attachMovie" or "createEmptyMovieClip". However, if we swap the depth of the movieClip instance to the programming space, then it can be removed. For example: myMc.swapDepths(2);myMc.removeMovieClip();

2.

When we swap or assign a depth of invalid number to the movieClip, it will be unremovable.

a. swapDepths to a number of greater than the limit.

The number must be less than 220. That is less than 1048576. Roughly, we can safely assign a number up to 6 digit of like 999999. We can swapDepths(1048575) and successfully removeMovieClip(). It is all right to assign a big big number to movieClip, but before we removeMovieClip, we need to swap its depth to valid numbber.

b. swapDepths to a negative number.

this.swapDepths(-1); Usually, this will put thie movieClip higher than every other movieClip. It is strange that, the smallest valid depths seems to be 0. swapDepths(0) will still bring it to front and will make movieClip removable.

What if we assign a depths of (0.2) ? It seems that, Flash will turn it into integer (not round). A depths of (1.2) is the same as depth of (1.4). Duplicate a movieClip at depths(1) will replace the movieClip at (1.2);

c. swapDepths to a string.

This is commonest mistake. Many may believe Flash treat string and number inter-changibly by loose typing. But it is not. Mc.swapDepths("2") will not affect the display. And it will be unremovable then. 

In Flash MX, when we swap the depth value of an instance to a "string", getDepths() will return a value like -16438 or so. Similar value can be obtained for a "normal" movieClip that is not created by duplicateMovieClip or attachMovie.

For all these unremovable movieClip, just swap it to valid depths and it is removable then.


A normal movieClip created by dragging from library will unload itself when balnk keyframe or next scene is played. While duplicated MovieClip will persist through all blank frames and even next scene.

Do you know ?!

If we swapDepths between normal clip and a duplicated clip, then the normal clip will be moved to virtual space while the duplicated clip will occupy the "normal" space. When blank keyframe or next scene is played, the one in "normal" space will be unloaded while the one in virtual space will be removed only by removeMovieClip().

@

@