矩形描画テスト
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();
}
}
}