var mc:Sprite = new Sprite(); init() 初始化讓程式更容易控制。a = a + 2 縮寫→ a += 2;i = i + 1 縮寫→ i++ 。var goback:int = 0; function moveCircle() { init(); } function init():void { mc.graphics.lineStyle(2,0x000000); mc.graphics.beginFill(0xFFCC00); mc.graphics.drawCircle(0,0,50); mc.graphics.endFill(); addChild(mc); mc.x = 200; mc.y = stage.stageHeight / 2; mc.addEventListener(Event.ENTER_FRAME, onMyEnterFrame); } function onMyEnterFrame(event:Event):void { if (mc.x > 250){ goback = 1; } else if (mc.x < 150){ goback = 0; } if (goback == 0){ mc.x += 2; } else { mc.x -= 2; } } moveCircle(); |
| 2007/08/14 03:05 |
Trackback Address :: http://blog.raienet.com/trackback/356
