Well you could....
But, while for..each does not guarantee any particular order, it does
not guarantee to be random either :-)
i.e. It might turn out that, in the next version of the flash player,
they find that they can have a more optimised implementation by
running the loop in array order.
Personally, I'd actually write the randomisation code, rather than
rely on internals. For a start, it won't exactly be obvious what the
code is even doing.
Peter
On 8/13/07, Johannes Nel <[EMAIL PROTECTED]> wrote:
> in as3 you could just dish it up using a for each loop
>
> On 8/13/07, Cedric Muller <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > There's that good old shuffleArray, don't know if that will be
> > sufficient:
> >
> > function shuffleArray (arr_p:Array):Array {
> > var len:Number = arr_p.length, mixed:Array = arr_p.slice(),
> > rn:Number, it:Number, el:Object;
> > for (it = 0; it<len; it++) {
> > el = mixed[it];
> > mixed[it] = mixed[rn = random(len)];
> > mixed[rn] = el;
> > }
> > return mixed;
> > }
> >
> > var myArr = new Array(40, 32, 90, 76, 66);
> > var rdnArr = shuffleArray(myArr);
> > // or
> > myArr = shuffleArray(myArr);
> >
> > hth,
> > cedric
> >
> >
> > > Hi
> > >
> > > I have one Array with random numbers [40,32,90,76,66]
> > >
> > > I need copy of this array but the order should be different and
> > > random.
> > > Something like this: [76,90,40,32,66]. How can this be done?
> > > Thanks for any help.
> > > _______________________________________________
> > > [email protected]
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software
> > > Premier Authorized Adobe Consulting and Training
> > > http://www.figleaf.com
> > > http://training.figleaf.com
> >
> > _______________________________________________
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
>
>
>
> --
> j:pn
> http://www.memorphic.com/news/
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com