# swapDepths tutorial code not working

**URL:** <https://forum.kirupa.com/t/swapdepths-tutorial-code-not-working/56023>\
**Category:** flash\
**Created:** [June 29, 2004, 10:37pm UTC](https://forum.kirupa.com/t/swapdepths-tutorial-code-not-working/56023 "2004-06-29T22:37:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonspain](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@simonspain](https://forum.kirupa.com/u/simonspain)\
**Post date:** [June 29, 2004, 10:37pm UTC](https://forum.kirupa.com/t/swapdepths-tutorial-code-not-working/56023/1 "2004-06-29T22:37:58Z")

</div>

i did the tutorial

[http://www.kirupa.com/developer/actionscript/swapdepth.htm](http://www.kirupa.com/developer/actionscript/swapdepth.htm)

on this site, but no joy…

only relevant code i can see in demo file is:

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

which i adapted to:

on (press) {  
\_root.x += 7;  
\_root.pic7mov.swapDepths(\_root.x);  
}

where pic7mov is an mc on the main timeline with a invButton on top layer with the code in it.

where is the code for the function x (which the tutorial says “resides on the main timeline”)… surely without it the code doesnt work… like javaScript it should relate to a function n’est pas?? i couldnt find it on example but example works ??
