# Using an object's parent

**URL:** <https://forum.kirupa.com/t/using-an-objects-parent/298266>\
**Category:** flash\
**Created:** [October 15, 2009, 6:21pm UTC](https://forum.kirupa.com/t/using-an-objects-parent/298266 "2009-10-15T18:21:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jik\_ff](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@jik\_ff](https://forum.kirupa.com/u/jik_ff)\
**Post date:** [October 15, 2009, 6:21pm UTC](https://forum.kirupa.com/t/using-an-objects-parent/298266/1 "2009-10-15T18:21:32Z")

</div>

I currently move an object from one container to another in a function of said obect. In the same function I wish to move it back to the initial container which is an extension of Sprite.

how do I reference it? Example, I have Sprite A that was in Sprite B. I move A into Sprite C (C.addChild(A)) within a function of A. Near the end of that function I wish to move A back into B (B.addChild(A)). In the function, B can initially be called as A.parent. C is created in this function, so it has it’s own variable. How do I reference B to be able to put A back into it?

I have tried to make a var in the function to track it:

```auto
var myParent = this.parent;

```

but I get this error:

> 

TypeError: Error #1034: Type Coercion failed: cannot convert [global@4177041](mailto:global@4177041) to flash.display.DisplayObject.  
at MethodInfo-23()  
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at flash.utils::Timer/flash.utils:Timer::tick()

I get other errors if I try and force the type to either Sprite or my extended class MenuWindow. Not an app killer, but more that I would like to know (or if this is the wrong way to do this, then a better way would be nice).
