forked from: getRandInt()
forked from getRandInt() (diff: 18)
unionのreactorに入っている便利ツールのひとつ getRandInt(min:int,max:int):int min以上max以下のランダムな整数を返します。 ↑を、書いてみた
ActionScript3 source code
/**
* Copyright undo ( http://wonderfl.net/user/undo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1Fga
*/
// forked from keno42's getRandInt()
// unionのreactorに入っている便利ツールのひとつ
// getRandInt(min:int,max:int):int
// min以上max以下のランダムな整数を返します。
// ↑を、書いてみた
package {
import flash.display.Sprite;
//import net.user1.utils.getRandInt;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
for( var i:int = 0; i < 100; i++ ){
graphics.lineStyle(0, getRandInt(0,0xFFFFFF));
graphics.drawCircle(getRandInt(0,465),getRandInt(0,465),getRandInt(0,30));
}
}
private function getRandInt(min:int, max:int):int
{
var randInt:int;
if(max < min)
{
var i:int = max;
max = min;
min = i;
}
var range:int = max - min + 1; //min<=randInt<=maxらしいので+1
randInt = min + Math.floor(Math.random()*range);
return randInt;
}
}
}
