Forked from: obanetty's [ASAnimation]1-1 moving ball diff:4 forked from: [ASAnimation]1-1 moving ball hioki forked:0favorite:0lines:30license : All rights reserved modified : 2009-02-15 20:53:40 Embed Tweet // forked from obanetty's [ASAnimation]1-1 moving ball package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; [SWF(width = 250, height = 500)] public class ASAnimation1_1 extends Sprite { //変化量 private var change:Number = 2; private var ball:Sprite; public function ASAnimation1_1() { //円を描く ball= new Sprite(); ball.graphics.beginFill(0x999999); ball.graphics.drawCircle(0, 0, 30); ball.graphics.endFill(); ball.x = stage.stageWidth / 2; ball.y = stage.stageHeight / 2; addChild(ball); //クリック時に動作するように stage.addEventListener(MouseEvent.CLICK, onClick); } private function onClick(event:MouseEvent):void { //ポイント1 addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(event:Event):void { //ポイント2 ball.x += change; } } } Code Fullscreen Preview Fullscreen MouseEvent.ENTER_FRAME MouseEvent.CLICK MouseEvent addEventListener addChild Number Sprite