範例「放風箏實況重播」中的指令文字 Layer controller 電影角色empty中的指令: __________________start here __________________ onClipEvent (load) { coordCount = 0; } onClipEvent (enterFrame) { if (_root.recordMode == 1) { if (_root.startRecord == 1) { coordsX = new Array(); coordsY = new Array(); coordCount = 0; _root.startRecord = 0; } coordCount++; coordsX[coordCount] = _root.kite._x; coordsY[coordCount] = _root.kite._y; } else if (_root.playBack == 1) { if (_root.startPlay == 1) { motherCoord = coordCount; coordCount = 0; _root.startPlay = 0; } if (coordCount<=motherCoord) { coordCount++; _root.kite._x = coordsX[coordCount]; _root.kite._y = coordsY[coordCount]; } else { _root.playBack = 0; _root.kite.velX = 0; _root.kite.velY = 0; } } updateAfterEvent(); } __________________end here __________________ Layer kite 電影角色kite中的指令: __________________start here __________________ onClipEvent (load) { friction = 0.9; velX = 0; velY = 0; currentX = this._x; currentY = this._y; } onClipEvent (enterFrame) { previousX = currentX; currentX = this._x; previousY = currentY; currentY = this._y; if (_root.kite == 0) { velX = (currentX-previousX)*friction; velY = (currentY-previousY)*friction; if ((this._x+velX)>=(300-(this._width/2)) or (this._x+velX)<=(0+(this._width/2))) { this._x -= velX; } else { this._x += velX; } if ((this._y+velY)>=(300-(this._width/2)) or (this._y+velY)<=(0+(this._width/2))) { this._y -= velY; } else { this._y += velY; } } } __________________end here __________________