With time saving in mind, I've written this weighted random function which makes beautiful randomness a lot handier to implement. For best results throw this in a class package and include it in every project.
Here it comes...
Please see right hand pane before copying my code >>
function round(num:Number, precision:int):Number{
var decimal:Number = Math.pow(10, precision);
return Math.round(decimal* num) / decimal;
}
function rand(to:Number, from=0, decimalPlaces=0, weightedRange=0, weightStrength=0):Number{
var ret
if(to == from){return(to);}
if(weightedRange && Math.random()<=weightStrength){
ret = round( Math.random()*(weightedRange[1]-weightedRange[0]) + weightedRange[0], decimalPlaces )
}else{
ret = round( Math.random()*(to-from)+from, decimalPlaces )
}
return(ret)
}
//USAGE:
rand(100) //return random number 0-100 INCLUSIVE
rand(10, -5) //return random number between -5 and 10
rand(10, -5, 2) //return random number between -5.00 and 10.00
rand(10, 6, 0, [0,5], 0.9) //90% chance of returning number between 0-5, 10% chance of returning number between 6-10
20 comments:
Hy, can you please send me your e-mail address, i want to ask you something it is not connect with this and don'y know how to contact except in this way? My is nidvanitri@msn.com
This is a very helpful function, thanks!
jordan 6 black infrared
north face coats
hermes belt
fitflop outlet store usa
under armour outlet
burberry scarf
gucci shoes
coach handbags
burberry sale
kevin durant shoes
north face jackets
converse shoes sale
coach factory outlet
air jordan 14
coach factory outlet online
louboutin outlet
fitflop sale
nike nfl jerseys 2015
north face outlet store
ugg boots
reebok outlet
michael kors handbags
christian louboutin sale
north face jackets clearance
new kevin durant shoes
nike clearance
toms outlet
dior handbags
michael kors outlet store
fitflops clearance
kate spade sale
jordan 12
ugg boots
coach purses sale
gucci outlet
wholesale jordans
canada goose clearance
1030wjl
1 columbia outlet
nike air max
polo shirts
polo shirts for women
north face outlet 70% off
cheap michael kors handbags
air jordan retro 6
salvatore ferragamo outlet
north face clearance
mbt shoes clearance outlet
reebok shoes outlet
polo ralph lauren factory store
celine handbags
christian louboutin shoes
michael kors handbags
fitflops online
jordan 6
ralph lauren extra 25% off
michael kors outlet
air jordan 11
coach factory online sale
jordan shoes
kd shoes
coach handbags outlet
coach shoes for women
gucci outlet
abercrombie and fitch outlet
ferragamo shoes outlet
air jordan 11 legend blue
michael kors factory outlet online
michael kors store
all jordan shoes
ugg boots sale
fitflop sandals for women
gucci outlet
cheap canada goose coats
nike running shoes
1030wjl
Greetings! I know this is somewhat off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having problems finding one? Thanks a lot!
unblocked games
unblocked games at school
unblockedgames
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
Discover our website bounty of free online games now!
Our website has the biggest collection of free online games. Totally new games are added every day!
age of war 2| gold Miner 2| unfair Mario 2 | cubefield 2 |tanki Online 2
canada goose
coach factory outlet
coach outlet
ray ban sunglasses
fit flops
canada goose jackets
kate spade outlet
cheap oakleys
birkenstock sandals
birkenstocks
20161228caiyan]
\
This is a great website. Good sparkling user interface and very informative blogs. I will be coming back in a bit, thanks for the great article. I have found it enormously useful. Clash of Kings download, Photo Grid Free, Douchebag Workout 2, Happy Wheels 4
coach outlet
michael kors outlet
nfl jerseys wholesale
christian louboutin outlet
coach outlet online
canada goose outlet
canada goose outlet store
canada goose outlet
christian louboutin sale
pandora outlet
shenyuhang20180608
20180623xiaoke
polo ralph lauren outlet
air max 2018
cheap jordans
canada goose jackets
coach outlet store online
dsquared2 jeans
cheap jordan shoes
oakley sunglasses wholesale
michael kors outlet clearance
coach outlet store online
Article very interisting, thanks for sharing information
Obat Untuk Mengikis Batu Ginjal
Cara Mengobati Benjolan Di Tangan
Pengobatan Atasi Radang Usus Buntu
Cara Mengobati Radang Pembuluh Darah
Cara Alami Mengobati Ginjal Bengkak
Pengobatan Fistula Ani Tanpa Operasi
Hello, we are from the health site admin, want to share our latest articles :
cara menghilangkan benjolan tumor
cara menyembuhkan radang lambung
cara menghilangkan benjolan di kelopak mata
cara mengobati batu empedu
cara mengobati kencing nanah
cara mengobati tipes
cara menghilangkan benjolan di belakang kepala
Superb article and valuable information because it’s really helpful for me, Thank you so much for share this wonderful information with us.
Jeans Manufacturers in Delhi
Such a very superb article, Very interesting to read this article, I would like to thank you for useful had made for writing this awesome article.
Top Commercial Vehicle Painters
Awesome article, Very interesting to read this article, I would like to thank you for useful had made for writing this superb article share with us.
Web design company
Great article, Very interesting to read this article, I would like to thank you for writing this helpful article share with us.
Motorcycle Tour in Mumbai
Good article, Very interesting to read this article, I would like to thank you for writing this helpful article share with us.
Lifestyle Magazine
Thanks for this awesome article Very interesting to read this article, Thank you sharing with us.
Shipping Company in India
Thank You! For sharing such a great article, It’s been a amazing article.
It’s provide lot’s of information, I really enjoyed to read this.
2
3
4
5
6 osg777 download
7
8
Post a Comment