In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: forked from: 2010-03-17_1

Get Adobe Flash player
by bkzen 17 Mar 2010
    Embed
/**
 * Copyright bkzen ( http://wonderfl.net/user/bkzen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zroK
 */

// forked from Kaede's forked from: forked from: 2010-03-17_1
// forked from Kaede's forked from: 2010-03-17_1
// forked from Kaede's 2010-03-17_1
package {
	import flash.text.TextField;
	import flash.display.BitmapData;
	import flash.geom.Matrix;
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.geom.Rectangle;
	import flash.geom.Point;
    import flash.utils.getTimer;
    public class FlashTest extends Sprite {
    	
    		private var n:int = 2001;
    		private var strs:Array = ["a","b","c","d","e","f","g","h"];
        public function FlashTest() {
            var nt:int = getTimer();

			example();
			
			var result:int = getTimer()-nt;

			var reTf:TextField = addChild(new TextField) as TextField;
			reTf.autoSize = "left";
			reTf.text = "resultTime = "+(result).toString()+", loop count : " + n;
			reTf.y = -20;
			y = 20;
			
        }
        
        //使用するデータをひとつのBitmapDataにプリレンダリングしておき、
        //別のBitmapDataにcopyPixelsで転写
        private function example():void{
			var length:int = strs.length;
			var tf:TextField = new TextField();
			tf.autoSize = "left";
			var bd:BitmapData = new BitmapData(80,20,false);
			var mtx:Matrix = new Matrix();
			var i: int, j: int, ny: int = Math.ceil(n / 50);
			while(i < length){
				tf.text = strs[i];
				mtx.tx = 10*i;
				bd.draw(tf,mtx);
				i++;
			}
			var bd2:BitmapData = new BitmapData(500,850,false);
			var pt:Point = new Point(0,0);
			var rect:Rectangle = new Rectangle(0,0,10,20);
			for (i = 0; i < ny; i++ )
			{
				for (j = 0; j < 50; j++ )
				{
					if (i * 50 + j == n) break ;
					pt.x = 10 * j;
					pt.y = 20 * i;
					rect.x = int(Math.random() * length) * 10;
					bd2.copyPixels(bd, rect, pt);
				}
			}
			/*
			i=0;
			while(i<n){
				pt.x=10*(i%50);
				pt.y=20*Math.floor(i/50);
				rect.x = Math.floor(Math.random()*length)*10;
				bd2.copyPixels(bd,rect,pt)
				i++;
			}
			*/
			addChild(new Bitmap(bd2));
        }
    }
}