# \[mx\] no swapDepth of AS-generated MC instances

**URL:** <https://forum.kirupa.com/t/mx-no-swapdepth-of-as-generated-mc-instances/41951>\
**Category:** flash\
**Created:** [February 3, 2004, 6:50pm UTC](https://forum.kirupa.com/t/mx-no-swapdepth-of-as-generated-mc-instances/41951 "2004-02-03T18:50:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![animes2k](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@animes2k](https://forum.kirupa.com/u/animes2k)\
**Post date:** [February 3, 2004, 6:50pm UTC](https://forum.kirupa.com/t/mx-no-swapdepth-of-as-generated-mc-instances/41951/1 "2004-02-03T18:50:23Z")

</div>

Hey there. Great resource here. Anyone feel like taking a stab at this, I sure would appreciate it.

I have a function that sets the highlight on a dynamically generated MC-button (so as to indicate it as the “selected” button).

The depth of every single dynamically generated button is -16384 (set by Flash, not me!). I am able to define a new “top” depth variable with each click of a button, but am not able to apply that depth to the button… Here’s my script:

// ++ with each new click, ensuring a true “top” depth  
var d = 0;

//called on initial movieclip duplication and each click of duplicated MC/button  
function setHilite(theButton) {  
d++;

```
trace("initial depth: " + getDepth(theButton)); //always -16384
howDeep = getDepth(theButton) + d; //a "top" variable

theButton.swapDepths(howDeep); //attempt to set "top" depth

trace("modified? " + howDeep); // returns "top" number - works fine
trace("final depth: " + getDepth(theButton)); // returns -16384, no change

```

}

There is other content in that script that’s not relevent and works fine on theButton (the actual visual highlight - a manipulation of an embedded MC’s \_alpha). The depth just isn’t getting set.

Any thoughts would be greatly appreciated.

Thanks!

- Chris
