好久未发帖了,刚才看到有人问到画sin后怎样移动所画的曲线,现举一小例,抛砖引玉...
效果如下:(并附源文件)
[1b]源文件:[/1b]
画sin.rar
以下代码直接拷贝到帧上就行了:
// x0 y0 起点坐标 | k 垂直幅度 | disX 水平幅度 disY 周期 | i 速度变量
var x0:Number = 100, y0:Number = 200, k:Number = 100, disX:Number = 2, disY:Number = 1, i:Number = 0;
//=== 画水平线背景 =======================
drawViewX();
function drawViewX() {
// wh 单元格长与宽
var wh:Number = 10;
this.createEmptyMovieClip("lineX", this.getNextHighestDepth());
onEnterFrame = function () {
with (lineX) {
lineStyle(1, 0xCCCCCC, 100);
moveTo(0, wh);
lineTo(Stage.width, wh);
}
if (lineX._width>=Stage.width) {
wh += 10;
}
if (wh>=Stage.height) {
delete onEnterFrame;
drawViewY();
}
updateAfterEvent();
};
}
//=== 画垂线背景 =========================
function drawViewY() {
// wh 单元格长与宽
var wh:Number = 10;
this.createEmptyMovieClip("lineY", this.getNextHighestDepth());
本文转自:http://www.5uflash.com/flashjiaocheng/Flashaschengxu/551.html