[mx] no swapDepth of AS-generated MC instances

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