Quick tip: Get a random number between 2 numbers in Flash.

I have a function I end up using in nearly every Flash project I do. It's dead simple, but really useful. It's called getRandom and it takes 2 numbers, and it will return a random number between those values. 

function getRandom(_min, _max):Number{
	var tNumber:Number;
	tNumber = Math.round(Math.random()*(_max-_min))+_min;
	return tNumber;
}

Now go off and make beautiful random numbers. (Or at least the beautiful sudo random numbers, since true random numbers are nearly impossible to generate from a computer, but that's another topic.)

There are no comments to this post.

Leave Your Comment:

name:

email:

location:

url:

your comment:

Remember my personal information

Notify me of follow-up comments?

Twitter Feed

John Morton talking on Twitter




Meanwhile on Instagram… //

My latest shot from Instagram.
#nyc