# Checking parent class or type

**URL:** https://forum.kirupa.com/t/checking-parent-class-or-type/330416
**Category:** flash
**Created:** [January 17, 2013, 8:32am UTC](https://forum.kirupa.com/t/checking-parent-class-or-type/330416 "2013-01-17T08:32:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Roman\_Ivanickij](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Roman\_Ivanickij](https://forum.kirupa.com/u/Roman_Ivanickij)
#### Post date: [January 17, 2013, 8:32am UTC](https://forum.kirupa.com/t/checking-parent-class-or-type/330416/1 "2013-01-17T08:32:02Z")

</div>

Hello  
I got a situation, where in my class i need to check parent class. I am trying that code inside class MenuItem

```auto
public function addItem(item:MenuItem):void {   
            if (item.parent is MenuItem) {code} // it doesnt work

```

and here is code how i am adding items to stage

```auto
var item3:MenuItem = new MenuItem("title");
var item3_1:MenuItem = new MenuItem("subtitle");
item3.addItem(item3_1);
addChild(item3);

```

so the idea is, to check, where my class item is added- to the same class or not. In case it called to the same class, i need to change that options.  
Please, help me
