# MovieClip = null?

**URL:** <https://forum.kirupa.com/t/movieclip-null/262729>\
**Category:** Uncategorized\
**Created:** [June 9, 2008, 3:07pm UTC](https://forum.kirupa.com/t/movieclip-null/262729 "2008-06-09T15:07:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gazurt](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gazurt/32/4060_2.png) [@Gazurt](https://forum.kirupa.com/u/Gazurt)\
**Post date:** [June 9, 2008, 3:07pm UTC](https://forum.kirupa.com/t/movieclip-null/262729/1 "2008-06-09T15:07:39Z")

</div>

Here is my code:

```auto
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:

```auto
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…

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [June 9, 2008, 3:40pm UTC](https://forum.kirupa.com/t/movieclip-null/262729/2 "2008-06-09T15:40:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gazurt](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gazurt/32/4060_2.png) [@Gazurt](https://forum.kirupa.com/u/Gazurt)\
**Post date:** [June 9, 2008, 3:56pm UTC](https://forum.kirupa.com/t/movieclip-null/262729/3 "2008-06-09T15:56:12Z")

</div>

> [@senocular;2339421](#):
>
> 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?

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

for(var i:Object in mc) {
delete mc*;
}

```

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

mc=null;

```

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

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [June 9, 2008, 3:59pm UTC](https://forum.kirupa.com/t/movieclip-null/262729/4 "2008-06-09T15:59:39Z")

</div>

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()
