Re: [Flashcoders] Determining probablity of a random pick.

2009-06-22 Thread Jiri
I see, that makes sense. Cheers. Jiri Paul Andrews wrote: Jiri wrote: Thank you i understand it. Could u please elloborate on the last part "..You can optimise this by using an array of pointers.." Do you mean that this; First calculated the range for each node. A = 0 - 5 B = 6 - 7 C =

Re: [Flashcoders] Determining probablity of a random pick.

2009-06-22 Thread Anthony Pace
An easy way is to if say you have 3 objects in a list given a weight options[0].weight = 1; options[1].weight = 3; options[2].weight = 4; instead of having it have three selections, you could add the weights and make it have 8 to choose from that point to the option. choice[0]=0; choice[1]=1;

Re: [Flashcoders] Determining probablity of a random pick.

2009-06-22 Thread Paul Andrews
Jiri wrote: Thank you i understand it. Could u please elloborate on the last part "..You can optimise this by using an array of pointers.." Do you mean that this; First calculated the range for each node. A = 0 - 5 B = 6 - 7 C = 8 - 10 Then store in an array like so? Array[0-5] = A Array[6

Re: [Flashcoders] Determining probablity of a random pick.

2009-06-22 Thread Jiri
Thank you i understand it. Could u please elloborate on the last part "..You can optimise this by using an array of pointers.." Do you mean that this; First calculated the range for each node. A = 0 - 5 B = 6 - 7 C = 8 - 10 Then store in an array like so? Array[0-5] = A Array[6-7] = B Array

Re: [Flashcoders] Determining probablity of a random pick.

2009-06-22 Thread Paul Andrews
Jiri wrote: Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight t

[Flashcoders] Determining probablity of a random pick.

2009-06-22 Thread Jiri
Hello list, I have an XMLList that can vary in length. I pick a random node each time using the simple method below: var tRandom:int = int(Math.random()*tXMLSource.nodes.length() ); return tXMLSource.nodes[tRandom] Now i would like to change it, so that I can specify a weight to each node.