# Swapping Depths Question

**URL:** <https://forum.kirupa.com/t/swapping-depths-question/118465>\
**Category:** Uncategorized\
**Created:** [August 5, 2004, 6:26pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465 "2004-08-05T18:26:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skurge](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Skurge](https://forum.kirupa.com/u/Skurge)\
**Post date:** [August 5, 2004, 6:26pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/1 "2004-08-05T18:26:39Z")

</div>

Hey all,

I’m testing out the following Kirupa tutorial:  
[http://www.kirupa.com/developer/actionscript/swapdepth.htm](http://www.kirupa.com/developer/actionscript/swapdepth.htm)

I got my movie to work and it’s called green.swf…

Problem is I’m calling the green.swf within a different master movie and loading it via “loadMovie” command. But when I call green.swf from my master movie the windows within green.swf no longer swapDepths like they do within green.swf.

Menu\_mc.One\_btn.onRollOver = function () {  
\_root.content\_mc.loadMovie(“swf/green.swf”);  
};

I’m referencing the swapDepths within green.swf using the following code for three windows…green…red…blue…the example for red is below:

on (press, release, dragOver, dragOut) {  
\_root.x +=2;  
\_root.red.swapDepths(\_root.x);  
}

I figure I’m not referencing the mc in green.swf correctly when it comes into the master movie but I’m not sure how it should be referenced.

Any help is greatly appreciated…

Regards,

SKURGE

---

<div class="post-metadata">

**Author:** ![coolname](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@coolname](https://forum.kirupa.com/u/coolname)\
**Post date:** [August 5, 2004, 6:32pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/2 "2004-08-05T18:32:32Z")

</div>

Maybe I have this wrong, but if you reference \_root from a movie loaded into a parent movie, \_root is the parent movie.

---

<div class="post-metadata">

**Author:** ![bwh2](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bwh2](https://forum.kirupa.com/u/bwh2)\
**Post date:** [August 5, 2004, 7:00pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/3 "2004-08-05T19:00:09Z")

</div>

try changing

> [@Skurge](#):
>
> on (press, release, dragOver, dragOut) {  
> \_root.x +=2;  
> \_root.red.swapDepths(\_root.x);  
> }

to [AS]on (press, release, dragOver, dragOut) {  
\_root.x +=2;  
\_root.content\_mc.red.swapDepths(\_root.x);[/AS]

---

<div class="post-metadata">

**Author:** ![coolname](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@coolname](https://forum.kirupa.com/u/coolname)\
**Post date:** [August 5, 2004, 7:05pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/4 "2004-08-05T19:05:45Z")

</div>

Couldn’t you also use the \_parent property?

---

<div class="post-metadata">

**Author:** ![bwh2](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bwh2](https://forum.kirupa.com/u/bwh2)\
**Post date:** [August 5, 2004, 7:08pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/5 "2004-08-05T19:08:05Z")

</div>

> [@coolname](#):
>
> Couldn’t you also use the \_parent property?

yep, i just wrote it my way b/c it might help someone understand the exact targeting problem easier.

---

<div class="post-metadata">

**Author:** ![Skurge](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Skurge](https://forum.kirupa.com/u/Skurge)\
**Post date:** [August 5, 2004, 8:23pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/6 "2004-08-05T20:23:22Z")

</div>

That works perfecty in the parent MC. THANKS!!

Is there anyway to compartmentalize the referencing so that the swapdepth call works nomatter their location or is the code you provided below the main way to do it and have it work when the mc is called from a parent movie?

Ex…  
\_root.content\_mc.blue.swapDepths(\_root.x);

---

<div class="post-metadata">

**Author:** ![bwh2](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bwh2](https://forum.kirupa.com/u/bwh2)\
**Post date:** [August 5, 2004, 8:45pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/7 "2004-08-05T20:45:44Z")

</div>

imagine using \_parent.mc as sort of a local reference, so it’s only going to work if the relationship between mc’s is correct. but the \_root.mc.mc is more of an absolute reference. so it will work in more situations.

---

<div class="post-metadata">

**Author:** ![Skurge](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Skurge](https://forum.kirupa.com/u/Skurge)\
**Post date:** [August 5, 2004, 9:18pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/8 "2004-08-05T21:18:09Z")

</div>

But I guess what your saying is that there really isn’t a way to reference it so that it works in all cases unless you have some variables in place and a procedure in place that will determine what variable to call depending on the location of where the MC is being called.

Do I understand it correctly?

Again thanks for your assistance!

SKURGE

---

<div class="post-metadata">

**Author:** ![bwh2](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bwh2](https://forum.kirupa.com/u/bwh2)\
**Post date:** [August 5, 2004, 9:23pm UTC](https://forum.kirupa.com/t/swapping-depths-question/118465/9 "2004-08-05T21:23:26Z")

</div>

yeah, i suppose using a variable like that would work. it would just be sort of unnecessary becuase you’d have to set up if statements, the variables, and still assign the variables the correct locations. it’s just easier to know the relative locations of your files and their relationships.
