my first test test coding うーん、なんかかっこ悪いなー ま、いっか。 uhauha909 forked:0favorite:0lines:53license : MIT License modified : 2011-05-22 18:43:24 Embed Tweet //test coding //うーん、なんかかっこ悪いなー //ま、いっか。 package { import flash.events.Event; import flash.display.Sprite; public class MyFirstTest extends Sprite { private const UP:String = "up"; private const DOWN:String = "down"; private const RIGHT:String = "right"; private const LEFT:String = "left"; private var status:String = RIGHT; private var square:Square; private var speed:int = 3; public function MyFirstTest() { // write as3 code here.. square = new Square(); this.addChild(square); this.addEventListener(Event.ENTER_FRAME, move); } private function move(e:Event):void { if (status == RIGHT){ square.x += speed; if(square.x > this.stage.stageWidth - square.width){ square.x = this.stage.stageWidth - square.width; status = DOWN; } } else if(status == DOWN){ square.y += speed; if(square.y > this.stage.stageHeight - square.height){ square.y = this.stage.stageHeight - square.height; status = LEFT; } } else if (status == LEFT){ square.x -= speed; if(square.x < 0){ square.x = 0; status = UP; } } else if(status == UP){ square.y -= speed; if(square.y < 0){ square.y = 0; status = RIGHT; } } } } } import flash.display.Sprite; class Square extends Sprite { public function Square(){ this.graphics.beginFill(0xFF0000); this.graphics.drawRect(0,0,100,100); this.graphics.endFill(); } } Code Fullscreen Preview Fullscreen test height width String addEventListener Event.ENTER_FRAME addChild Event Sprite int