# If layer confusion

**URL:** <https://forum.kirupa.com/t/if-layer-confusion/25241>\
**Category:** flash\
**Created:** [July 10, 2003, 8:18pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241 "2003-07-10T20:18:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meridian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/meridian/32/243_2.png) [@Meridian](https://forum.kirupa.com/u/Meridian)\
**Post date:** [July 10, 2003, 8:18pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/1 "2003-07-10T20:18:23Z")

</div>

Ok I have 2 movies loading on 2 different levels…

player wich loads on level201 and hover with loads on level200

I’d like the bottom one (level200) to see if it’s on level200 when clicked and then swap with level201.

So I thought an if statement would work nicely… but I’m missing something… or I’ve confused myself (wich has my vote)

[AS]  
if (\_root.hover.getDepth() == \_level200) {  
\_level200.swapDepths(\_level201);  
}

[/AS]

and visa versa

[AS]  
if (\_root.player.getDepth() == \_level200) {  
\_level200.swapDepths(\_level201);  
}  
[/AS]

What am I missing?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2003, 8:26pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/2 "2003-07-10T20:26:03Z")

</div>

your missing the  
[AS]on (release) {  
blah blah  
}[/AS]  
part as far as i can tell

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2003, 8:28pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/3 "2003-07-10T20:28:55Z")

</div>

Heh no that’s there…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2003, 8:47pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/4 "2003-07-10T20:47:12Z")

</div>

instead of doing the \_level#.swapDepths(\_level#+1)

can you just do

player.swapDepths(hover);

Seems to work for me. I have never seen the swapDepths done with the level, just the movie name

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2003, 8:56pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/5 "2003-07-10T20:56:22Z")

</div>

well the 2 movie clips are being loaded into 2 different levels so calling them by their instance names wount work, and by level is the only way to call them.

That’s why I’m using getdepth to determine their depth first then is that info is correct swap

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2003, 9:16pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/6 "2003-07-10T21:16:40Z")

</div>

Ok, but I don’t know how you’re going to swap a level. Because there is no function for it. The swapDepths() function is for a movie clip instance name and another movie clip instance name. You’ll have to do something like:

[AS]  
if (\_root.hover.getDepth() == \_level200) {  
\_level200.hover.swapDepths(\_level201.player);  
}

if (\_root.player.getDepth() == \_level200) {  
\_level200.player.swapDepths(\_level201.hover);  
}

[/AS]

I am a little confused though, because you are calling hover and player from \_root, meaning that they should both be able to swap depths. I would recommend trying it without the \_levels. Also, do you know if getDepth() returns a \_level# or does it just return a number? because if that condition is never true, it will never do that stuff.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2003, 10:19pm UTC](https://forum.kirupa.com/t/if-layer-confusion/25241/7 "2003-07-10T22:19:26Z")

</div>

All I’m tyring to get it to do is test and see what level it’s on and if it’s on one level then swap its self with another level once clicked on…

The reason I’m isuing \_root is well… the code is inside popup.swf that has a mc called hover. So I’m using \_root.hover to give it an absolute path.
