# swapDepths and onRelease actions problem

**URL:** <https://forum.kirupa.com/t/swapdepths-and-onrelease-actions-problem/328665>\
**Category:** flash\
**Created:** [June 4, 2012, 2:36pm UTC](https://forum.kirupa.com/t/swapdepths-and-onrelease-actions-problem/328665 "2012-06-04T14:36:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fastrix](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fastrix](https://forum.kirupa.com/u/fastrix)\
**Post date:** [June 4, 2012, 2:36pm UTC](https://forum.kirupa.com/t/swapdepths-and-onrelease-actions-problem/328665/1 "2012-06-04T14:36:29Z")

</div>

[COLOR=#000000][FONT=verdana]I hope u can help me again!!! There’re buttons that need to scale at max when rollover but they appear ones back of anothers. Tried the swapDepths method for buttons:  
[/FONT][/COLOR]

```auto
Button.prototype.swapDepths = MovieClip.prototype.swapDepths;

this.onRollOver = function():Void{
    origDepth = this.getDepth();
    this.swapDepths(_root.getNextHighestDepth());
}
this.onRollOut = function():Void{
    this.swapDepths(origDepth);
}

```

[COLOR=#000000][FONT=verdana]but when rollOut the rollOver instance of the button remains visible and so on for each button.[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]I started a search and found that its better if u use swapDepths with movieclips instead of buttons. I changed the buttons to movieclips and the code is working perfectly for the swapDepths but when i try an onRelease function in timeline or on(release) in the mc, the actions doesnt work. When is used in the buttons it works perfectly but not the swapDepths.[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]The code im using works to populate a list and i cant figure out what is wrong. Here is the code that im using on realeses:  
[/FONT][/COLOR]

```auto
for(var i:Number=0;i<11;i++)
    {
        var visibleCheck:String = new String("textMC"+i);
        var visibleCheck:String = new String("x"+i);
         
        if(this[visibleCheck]._visible==false)
        {
            this["textMC"+i]._visible=true;
            this["textMC"+i].txtbox.text="eggs";
            this["textMC"+i].image_mc.loadMovie("images/eggs.png");
            this["textMC"+i].prot.text="9";
            this["textMC"+i].carb.text="8";
            this["textMC"+i].fat.text="2";
            this["textMC"+i].sugar.text="4";
            this["x"+i]._visible=true;
            calculate();
            return;
        }
    }

```

[COLOR=#000000][FONT=verdana]Also added a [link to my project](http://www.mediafire.com/?b6ptwgur8itabac) for better understanding of the whole code.

Pretty please help me!!![/FONT][/COLOR]:puzzle:
