# AS2 - Rearrange Array - reposition movie clips

**URL:** <https://forum.kirupa.com/t/as2-rearrange-array-reposition-movie-clips/290710>\
**Category:** flash\
**Created:** [June 18, 2009, 3:44pm UTC](https://forum.kirupa.com/t/as2-rearrange-array-reposition-movie-clips/290710 "2009-06-18T15:44:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goomy](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@goomy](https://forum.kirupa.com/u/goomy)\
**Post date:** [June 18, 2009, 3:44pm UTC](https://forum.kirupa.com/t/as2-rearrange-array-reposition-movie-clips/290710/1 "2009-06-18T15:44:11Z")

</div>

Hi there,

Im using zOrder - swapdepths array manipulation file.

Import movie clips into array. close movie button works fine. what i want to do is shift everything below closed button to eliminate the gap. I tried to reposition that with loop and use of .\_y = but I am sure i messed it up. I pasted code below. Anyone have idea how to sort it out? Thanks

Goomy

```auto
// zOrder.fla by Nathan ****en - nathand@boxerjam.com (or) nk****en@aol.com
// to be used for educational purposes only :)
// this is a new version - sorry for the latest "buggy" one
// ..........................................................

// create new array for monitoring z-order
zOrderList = new Array("0");

defaultX = 100;
defaultY = 100;
increment = 25;
id = 0

// create a new windowObj...
function windowObj (title, content) {

    // get the current depth based on the array
    id++
    var depth = id;
    trace("id: "+id);

    // create 
    _root.attachMovie("window", "window"+id, id);
    this.window = _root["window"+id];

    // position
    this.window._y = defaultY+((id-1)*increment);

    // set data
    this.window.title = title;
    this.window.content = content;
    this.window.myID = id;
    this.window.myDepth = zOrderList.length;

    zOrderList.push(id);    

}

// delete windowObj and splice zOrderList...
function closeWindow (incomingDepth) {

    _root["window" + zOrderList[incomingDepth]].removeMovieClip();
    
    zOrderList.splice(incomingDepth, 1);

    for (i=incomingDepth; i<zOrderList.length; i++) {
        // change each windowObj's depth
        _root["window"+zOrderList*].myDepth-- ;
    }

}

```

I uploaded FLA file as well here: [http://goomys.com/kirupa/arraytest\_kirupa.fla](http://goomys.com/kirupa/arraytest_kirupa.fla)

Any help appreciated
