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 suica 09 Jan 2010
package {
	import flash.ui.Keyboard;
	import flash.utils.IDataInput;
	import flash.text.TextFormat;
	import flash.text.TextField;
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    import flash.events.Event;
    public class FlashTest extends Sprite {
    		private var mouseCount:int = 0;
    		private var frame:int = 0;
    		private var text:TextField = null;
    		private var sp:Sprite;
        public function FlashTest() {
            // write as3 code here..
            text = new TextField();
            sp = new Sprite();
            
            text.defaultTextFormat = new TextFormat("_sans", 20);
            text.x = 0;
            text.y = 0;
            text.width = 400;
            text.textColor = 0xAAAAAA;
            addChild(sp);
            sp.addChild(text);
            
            stage.addEventListener(KeyboardEvent.KEY_DOWN,
            		function(e:KeyboardEvent):void{
            		mouseCount++;
            });
            stage.addEventListener(Event.ENTER_FRAME,enterFrame);
        }
        
        private function enterFrame(ev:Event):void
        {
        		var v:int = mouseCount;
//        		this.text.backgroundColor = (((v*3) % 0xff)<<16 + ((v*2)%0xff)<<8 + ((v*8)%0xff));
            this.text.text = "Hit KeyBoard: " + v + " frame: " + frame;
            moveRect();
            
            frame++;
        }
        
        private function moveRect():void
        {
        		var x:int = (frame *20) % 400;
        		var y:int = (int(frame / 20) * 20) % 400;
        		var color:int = frame % 0xff;
        		sp.graphics.beginFill(0xFFFFFF * Math.random());
        		sp.graphics.drawRect(x,y,20,20);
        		sp.graphics.endFill();
        }
    }
}