# Swap Depth

**URL:** <https://forum.kirupa.com/t/swap-depth/253331>\
**Category:** flash\
**Created:** [February 29, 2008, 5:28am UTC](https://forum.kirupa.com/t/swap-depth/253331 "2008-02-29T05:28:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![james182](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@james182](https://forum.kirupa.com/u/james182)\
**Post date:** [February 29, 2008, 5:28am UTC](https://forum.kirupa.com/t/swap-depth/253331/1 "2008-02-29T05:28:36Z")

</div>

i have 3 button that load 3 images, i have 2 movieClips when first button is clicked it loads 1 movieClip with the image and the 2nd button clicked once loaded would fade out the first(top) mc . and it would just keep swaping based on if its loaded.

```php
function swapPhoto(newHero) {
    var currHero = newHero;
    if (newHero == currHero) {
        _root.picture.loadMovie(newHero);
        _root.picture.swapDepths(_root.picture2);
        trace("D1");
    } else {
        _root.picture.loadMovie(currHero);
        _root.picture2.swapDepths(_root.picture);
        trace("D2");
    }
}

```
