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

素数で何か

素数で何か!って思ったけど…。
Get Adobe Flash player
by 178ep3 05 Dec 2009
    Embed
/**
 * Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t2Ck
 */

//素数で何か!って思ったけど…。
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;

	public class Test extends Sprite
	{
		private var i:uint = 3;
		private var _list:Array = [2];
		private var _bmp:Bitmap;
		
		public function Test()
		{
			_bmp = addChild(new Bitmap(new BitmapData(15,930,false,0xffffff)))as Bitmap;
			_bmp.x = 15;
			_bmp.scaleX=30;
			_bmp.scaleY=0.5;
			_bmp.bitmapData.setPixel(14,1,0);
			
			addEventListener(Event.ENTER_FRAME,loop);
		}
		
		private function loop(e:Event):void
		{
			var flg:Boolean = true;
			var q:uint;
			var len:uint;
			
			for(var w:uint=0; w<2; w++)
			{	
				flg = true;
				len = _list.length;
				for(q=0; q<len; q++)
				{
					if(i%_list[q]==0)
					{
						flg=false;
						break;
					}
				}
				if(flg)
				{
					_list.push(i);
					var number:String = String(i.toString(2));
					var x:uint=0;
					var y:uint = len++;
					len = number.length;
					
					for(q=0; q<len; q++)
					{
						x = 15-len + q;
						if(number.charAt(q)=="1")_bmp.bitmapData.setPixel(x,y,0);
					}
					if(y==930)removeEventListener(Event.ENTER_FRAME,loop);
				}
				i+=2;
			}
		}
	}
}