2 Replies Latest reply on May 29, 2008 11:27 PM by Projectpixel

    Dynamic list order change

    Projectpixel
      Hi,

      I have a list of 8 items. I want to move items up or down the list by clicking on the up or down arrows next to each item. I just can't figure this out. Each item is a movie clip with 8 frames, each frame has one of the 8 items on it. IE frame 1 = item 1.

      This is what the list looks like, those are 8 movieclips
      http://xs127.xs.to/xs127/08223/listitems393.png

      This is what I have inside my movieclips
      http://xs127.xs.to/xs127/08223/mcframes159.png


      It sounds simpler than it is. Obviously the clips need to rearrange themselves according to the positions(keyFrames) of the others.


      Thanks in advance
        • 1. Re: Dynamic list order change
          Ned Murphy Adobe Community Professional & MVP
          You probably have 7 more items and 7 more frames than you need if I'm interpretting your description property.

          You should be able to have one of those frame items as a movieclip, where you have 8 of them total, sharing the same frame. You can then use their _y location properties to control which items are where on the list. The _y location values could be stored as fixed values in an array.

          Each item could carry a position variable indicating where it currently is, so that when when you click its up or down button it exchanges _y positions with whichever item's position variable occupies the destination space, using a loop to find out which item has that position.

          If a piece occupies the first or last position, then moving it up or down, respectively is denied.

          It's simpler than it might sound.

          If there is some reason you need to have all 8/64 of the items you identified, you will need to explain a little more about what you are trying to do.
          • 2. Re: Dynamic list order change
            Projectpixel Level 1
            The reason that I used 8 instances of the same clip was that instead of actually changing the objects position, I was changing the frame on the clip. So that in order to move object one(frame one) down one position, I would change instance two to frame 1 and in turn instance 1 to frame 2. Essentially swapping positions in the list.

            I'm sure using arrays is the answer, but I find them a bit daunting. Perhaps using an array to list the items and then placing them in the correct order in text fields would be easier than moving them around on the stage? Could you point me in the right direction with regards to keeping the objects in an array and rearranging the array according to the user interaction?

            Thanks