# removeChild()

**URL:** <https://forum.kirupa.com/t/removechild/290935>\
**Category:** flash\
**Created:** [June 22, 2009, 2:14pm UTC](https://forum.kirupa.com/t/removechild/290935 "2009-06-22T14:14:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [June 22, 2009, 2:14pm UTC](https://forum.kirupa.com/t/removechild/290935/1 "2009-06-22T14:14:24Z")

</div>

Hi - In my simple code I am adding a swf via addChild.  
Fine.

```auto
var nws:Loader = new Loader()
    nws.load(new URLRequest("news.swf"))
    addChild(nws)

```

however further on in my code - I want this swf or nws var to be removed when clicking on another button … so I use removeChild(nws); within another function.

But AS3 comes up with an error saying that nws is undefined property with this removeChild line.

How else can I say “when nws is loaded - and upon clicking this button - remove it” ??

Thanks …//
