# Referrencing Objects in Different Levels

**URL:** <https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456>\
**Category:** flash\
**Created:** [July 9, 2008, 5:15am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456 "2008-07-09T05:15:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 5:15am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/1 "2008-07-09T05:15:14Z")

</div>

Hi,

Can someone Please help me out with how to reference objects in different levelts

There’s The Main Scene and two movie clips in the timeline

```
Movie Clip (loading_mc)
Movie Clip (scrolling)

```

how do we call for something in “loading\_mc” from “scrolling” and visa versa

What im after is to remove a child added by “scrolling” using a script in “loading\_mc”

Plzzz im stuck!!

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [July 9, 2008, 5:19am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/2 "2008-07-09T05:19:02Z")

</div>

Use parent to access the main scene then reference them from there.

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 5:22am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/3 "2008-07-09T05:22:27Z")

</div>

the parent and child is a bit confusing to me still… so if you can write a piece of code that would help me better… Sorry for the fuzz im new to AS3

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [July 9, 2008, 5:25am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/4 "2008-07-09T05:25:11Z")

</div>

If you were in _loading\_mc_, you would write _parent.scrolling_.

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 5:32am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/5 "2008-07-09T05:32:38Z")

</div>

Thanks mate… what i herd was that we cant use names to refer movie clips in AS3 but i will try this… This all worked fine in AS2 but im trying to migrate to AS3 and having some issues

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [July 9, 2008, 5:35am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/6 "2008-07-09T05:35:54Z")

</div>

[QUOTE=flashhash;2355574]Thanks mate… what i herd was that we cant use names to refer movie clips in AS3 but i will try this… This all worked fine in AS2 but im trying to migrate to AS3 and having some issues[/QUOTE]  
Whoever told you that is wrong.

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 5:50am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/7 "2008-07-09T05:50:52Z")

</div>

All i get is this

1119: Access of possibly undefined property scrinside through a reference with static type flash.display:DisplayObjectContainer.

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 6:03am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/8 "2008-07-09T06:03:06Z")

</div>

This is line of code i want to correct

“parent. **\_scr**.removeChild(thisMC);”

\_scr being the instance name of the movie clip

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 6:10am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/9 "2008-07-09T06:10:57Z")

</div>

ok i got that to work…

it should actually be MovieClip(root).\_scr.removeChild(thisMC);

but now im getting an argument error saying the Caller is not the parent of the Display object.

can someone tell me the the way to removeChild(thisMC) from the other movie clip

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [July 9, 2008, 7:44pm UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/10 "2008-07-09T19:44:38Z")

</div>

I’m not sure I understand your setup, but try this:

_parent.removeChild(thisMC);_

---

<div class="post-metadata">

**Author:** ![Sentientv2](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Sentientv2](https://forum.kirupa.com/u/Sentientv2)\
**Post date:** [July 9, 2008, 7:55pm UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/11 "2008-07-09T19:55:36Z")

</div>

I’m not sure if this helps, but if you can add the movie clips in the first place by making an instance of them (using their class Identifier in the Linkage properties). That way you can just type "removeChild(name of your instance) and since you added it through that class, it will disappear.

I’m not sure personally how you would do a pre-existing class, perhaps you need an instance name and linkage properties set up.

UPDATE: Yea, that worked for me. I had a pre-existing movie clip on the stage. I set up it’s linkage properties, and gave the instance on the stage a name. Then I simply did, removeChild(instancename).

Here’s my example. I have a movie clip object that is on the stage. The name of the movie clip in the library is menuBar. I set up the linkage properties (so my document class can see it). I then set the object on the stage to the instance name “thisMenuBar”. Here is what my document class, Document.as, looks like:

---

<div class="post-metadata">

**Author:** ![Sentientv2](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Sentientv2](https://forum.kirupa.com/u/Sentientv2)\
**Post date:** [July 9, 2008, 8:01pm UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/12 "2008-07-09T20:01:43Z")

</div>

Man, this site’s advanced mode and Firefox3 on my mac are not playing nicely… sorry this isn’t code formatted,

package {  
//import flash.geom._;  
import flash.display._;

```
public class Document extends Sprite {
	public function Document() {
		removeChild(thisMenuBar);
	}
}

```

}

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 10, 2008, 12:21am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/13 "2008-07-10T00:21:06Z")

</div>

Thanks i finally figured out how to do it… i had to create a function in the MovieClip “scroll”

function \_unLoad():void{  
SoundMixer.stopAll();  
thisLoader.unload();  
MovieClip(root).removeChild(thisMC);  
}

and call that function from the other movieclip “loading\_mc”

but that lead to another problem…

```
 i'm calling thisMC from both MovieClips so i need to find out how to refer to the caller..

```

btw im not using classes… i need to start doing that… my code’s getting complicated

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [July 10, 2008, 12:29am UTC](https://forum.kirupa.com/t/referrencing-objects-in-different-levels/265456/14 "2008-07-10T00:29:40Z")

</div>

Did you try:

```auto

thisMC.parent.removeChild(thisMC);

```
