[Flash] http://blog.raienet.com/attach/1/1259740437.swf



var mc:Sprite = new Sprite();
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();
init() 初始化讓程式更容易控制。a = a + 2 縮寫→ a += 2;i = i + 1 縮寫→ i++ 。
2007/08/14 03:05 2007/08/14 03:05
2007/08/14 03:05 

Trackback Address :: http://blog.raienet.com/trackback/356


[◀ PREV][1]... [85][86][87][88][89][90][91][92][93]... [407][NEXT ▶]