0
So, there's quite a few ways to do this, but, the easiest way to calculate raall the values need to add up to \$1\$.
Consider decimals as percentages, for example: \$40\%\$ would be \$0.4\$.
Which means, this needs to go/change:
var treasureItemsWeights:Object = { "1" : 5 , "2" : 20, "3" : 40...