MovieClip = null?

Here is my code:

var my_mc:MovieClip = new MovieClip();
addChild(my_mc);
//
my_mc.some_variable="as3"

trace(my_mc.some_variable);
removeChild(my_mc);
trace(my_mc.some_variable);

If can remove movieclip but cant remove its data? I tried this:

var my_mc:MovieClip = new MovieClip();
addChild(my_mc);
//
my_mc.some_variable="as3"

trace(my_mc.some_variable);
removeChild(my_mc);
my_mc=null;
trace(my_mc.some_variable);

Is this true way of removing a MovieClip? Thanks…

removeChild “removes” the movie clip. But the movie clip’s existence does not depend on whether or not the movie clip has been “added”. Just look at how you make a new movie clip: new MovieClip(). Its not added to the screen there. Its just a value in a variable. As long as that value exists, so will the movie clip, whether or not its actually been added to the display list (via addChild) and visible on the screen. Setting your variable (or variables) to null and removing the movie clip will get rid of it, or at least internally let the Flash Player know that it can be deleted since true deletion is handled behind the scenes in Flash for you.

Thanks for your reply :sen: Then are these same?

var mc:MovieClip = new MovieClip();
addChild(mc);

for(var i:Object in mc) {
delete mc*;
}
var mc:MovieClip = new MovieClip();
addChild(mc);

mc=null;

[COLOR=#000000][COLOR=#007700][/COLOR][COLOR=#FF8000][/COLOR][/COLOR]

No… not exactly. The for loop is doing nothing. What that would do is go through the dynamic properties of mc and delete them, but there are none, so it shouldn’t do anything.

The second example is setting your mc variable to null. This isn’t getting rid of the movie clip because you also added it to the screen and didn’t remove it. So there still exists a way to reference it, though instead of mc (which is now null) you could use getChild()