forked from: random_LCG

by makc3d forked from random_LCG (diff: 6)
♥0 | Line 38 | Modified 2013-08-14 10:13:39 | MIT License
play

ActionScript3 source code

/**
 * Copyright makc3d ( http://wonderfl.net/user/makc3d )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8wfv
 */

// forked from greentec's random_LCG
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 = 31415926;
        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<200000)
            {
                screenBitmap.lock();
                for(var i:int=0;i<1000;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());
                }
                screenBitmap.unlock();
            }
            
            
        }
        
        public static function random():Number 
        {
            num = (num * 1664625 + 1013904223) % 0x100000000;
            return num / 0x100000000;
        }


        
    }
}

Forked