random_LCG
♥0 |
Line 36 |
Modified 2013-08-13 22:35:48 |
MIT License
archived:2017-03-20 00:58:58
ActionScript3 source code
/**
* Copyright greentec ( http://wonderfl.net/user/greentec )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gmJu
*/
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import com.bit101.components.Label;
public class FlashTest extends Sprite {
public var screenBitmap:BitmapData;
public static var num:Number = 1;
public var pointNum:uint=0;
public var _label:Label;
//public var _label2:Label;
public function FlashTest() {
// write as3 code here..
//Style.setStyle(Style.DARK);
_label = new Label(this, 10, 10, "");
//_label.color = 0xffffff;
//_label2 = new Label(this, 10, 30);
screenBitmap = new BitmapData(465, 465, true, 0xffffffff);
addChild(new Bitmap(screenBitmap));
addEventListener(Event.ENTER_FRAME, onLoop);
}
public function onLoop(e:Event):void
{
if(pointNum<50000)
{
for(var i:int=0;i<10;i+=1)
{
//screenBitmap.setPixel32(random()*465, random()*465, 0x11000000);
//screenBitmap.setPixel32(Math.random()*465, Math.random()*465, 0x80ffffff);
screenBitmap.setPixel32(100 + random()*265, 100 + random()*265, 0x80000000);
pointNum += 1;
_label.text = "iteration : " + String(pointNum);
//_label2.text = String(random());
}
}
}
public static function random():Number
{
num = (num * 1664625 + 1013904223) % 0x100000000;
return num / 0x100000000;
}
}
}