School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,412 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,582 people online right now. Registration is fast and FREE... Join Now!




Array - rearrange movie clips in array

 

Array - rearrange movie clips in array

goomy

18 Jun, 2009 - 07:52 AM
Post #1

New D.I.C Head
*

Joined: 21 Nov, 2008
Posts: 6

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

CODE
// 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[i]].myDepth--;
    }

}


I uploaded FLA file as well here: http://goomys.com/kirupa/arraytest_kirupa.fla

Any help appreciated

User is offlineProfile CardPM
+Quote Post


SwiftStriker00

RE: Array - Rearrange Movie Clips In Array

24 Jun, 2009 - 05:12 AM
Post #2

D.I.C Regular
Group Icon

Joined: 25 Dec, 2008
Posts: 295



Thanked: 18 times
Dream Kudos: 125
My Contributions
QUOTE(goomy @ 18 Jun, 2009 - 09:52 AM) *

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

CODE
// 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[i]].myDepth--;
    }

}


I uploaded FLA file as well here: http://goomys.com/kirupa/arraytest_kirupa.fla

Any help appreciated



I only know AS3, but as your looping, and the iteration is greater than the index removed, shift 25pixels and then call the addChild method again on the object. you dont need to remove first since addChild will just remove and insert into spot on stage w/ new cords.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 11:11PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month