# If(variable exists)

**URL:** https://forum.kirupa.com/t/if-variable-exists/319188
**Category:** flash
**Created:** [February 11, 2011, 9:18am UTC](https://forum.kirupa.com/t/if-variable-exists/319188 "2011-02-11T09:18:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Nature](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nature](https://forum.kirupa.com/u/Nature)
#### Post date: [February 11, 2011, 9:18am UTC](https://forum.kirupa.com/t/if-variable-exists/319188/1 "2011-02-11T09:18:11Z")

</div>

Hi kirupa,

I’ve got a movieclip in my library which can have another movieclip inside it. Now I want to check if it’s there. Searching online gives:

```auto
var mc1:MovieClip = new MC1();
if(mc1.mc2)
    //mc2 exists

```

but this code will give me an compile error when ‘mc2’ does not exist:

```auto
1119: Access of possibly undefined property mc2 through a reference ....

```

Is there anyway to get what I want?
