A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: MovieClip Instance Sorting

  1. #1
    Junior Member
    Join Date
    Jul 2001

    MovieClip Instance Sorting

    First off, I am going to let all of you into a deep dark secret. Every two weeks a bunch of friends of mine get together and have a "poker night" thing...well some people have poker night, my friends and I have Dungeons and Dragons night. What can I say D&D ended up being fun, who knew.

    Anyways heres my issue. I am creating a stand-alone application for myself when I am DMing the game (Am I digging a bigger nerd hole everytime I speak or what?) and what I want to do is collect the variables from the players, lets say there is 4 players and depending on what they rolled, the highest number will get to go first. for Example:

    The Rolls
    Charlie rolled a 20
    Amber rolled a 15
    Phillip rolled a 6
    Daniel rolled a 16

    The Order of Play
    Charlie rolled a 20
    Daniel rolled a 16
    Amber rolled a 15
    Phillip rolled a 6

    What I am currently stuck on my tool is that I want to get this information than automatically sort the order of each person like the above. How can I tie the name of the player to the number is really what I am asking. Thanks guys. Hopefully there will be some peeps out there that understand D&D and how it works and go "I KNOW WHAT YOUR SAYIN'!".

    - Pauly
    Nerd at Large

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    use Array.sortOn to sort the order
    arr = [];
    arr[0] ={Name:"Charlie",Roll:20};
    arr[1] ={Name:"Amber",Roll:15};
    arr[2] ={Name:"Phillip",Roll:6};
    arr[3] ={Name:"Daniel",Roll:16};
    arr.sortOn("Roll",Array.NUMERIC | Array.DESCENDING);
    for(var n=0;n!=arr.length;n++){
    trace(arr[n].Roll+" -- "+arr[n].Name);
    output will show -

    20 -- Charlie
    16 -- Daniel
    15 -- Amber
    6 -- Phillip

    hope this helps you on your way

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center