Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: FLASH: Shuffling the contents of an array
From: Damien Morton
Date: Sun, 24 Sep 2000 00:54:10 +0100

list = [1,2,3,4,5,6]; // doesnt necessarily need to be ordered
// list can contain any objects: strings, movieclips, whatever

function shuffle(list) {
srclist = list.slice(); // make a copy for ourselves to destroy
randomlist = [];
while (srclist.length > 0)
randomlist.push(srclist.splice(random(srclist.length), 1));
return randomlist;
}

> -----Original Message-----
> From: Paul Steven [p [dot] stevenatbtinternet [dot] com (mailto:p [dot] stevenatbtinternet [dot] com)]
> Sent: Saturday, September 23, 2000 2:38 PM
> To: flasheratchinwag [dot] com
> Subject: FLASH: Shuffling the contents of an array
>
>
> Hi there
>
> I have an array that has three items in it
>
> e.g Array_Of_Directions=["Right","Down","Up"]
>
> I want to randomly change the positions of each element so
> that everytime I
> loop through using the elements in the array I don't get the
> same one first
> every time.
>
> So sometimes it would be ["Down","Up","Right"]
>
> and sometimes ["Up,"Right","Down"]
>
> etc
>
> Any ideas of a simple way to do this?
>
> Thanks
>
> Paul
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> NudeGuru.com is proud to sponsor the Flasher list
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> IT'S THE ART OF MONEY, HONEY!
> Tips and Advice from some of the most popular Flash
> artists + industry power-brokers on how to hold onto
> your rights, negotiate contracts and get full value
> for your work.http://www.nudeguru.com from Franke James
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> To unsubscribe or change your list settings go to
> http://www.chinwag.com/flasher or email helpatchinwag [dot] com
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NudeGuru.com is proud to sponsor the Flasher list
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IT'S THE ART OF MONEY, HONEY!
Tips and Advice from some of the most popular Flash
artists + industry power-brokers on how to hold onto
your rights, negotiate contracts and get full value
for your work.http://www.nudeguru.com from Franke James
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]