举一个例子:(折线运动)
_root.ball.onLoad = function() {
//取得小球的初始坐标;
inX = getProperty(_root.ball, _x);
inY = getProperty(_root.ball, _y);
};
_root.ball.onLoad();
//定义速度;
dx = 3;
dy = 3;
_root.ball.onEnterFrame = function() {
//使小球运动;
this._x += dx;
this._y -= dy;
//取得小球运动中的坐标
mvX = getProperty(_root.ball, _x);
mvY = getProperty(_root.ball, _y);
//运用求弦公式,当小球运动的路程大于300像素时,使dy为负数;
if (Math.sqrt((mvX-inX)*(mvX-inX)+(mvY-inY)*(mvY-inY))>=300) {
dy = -3;
}
};
.
- 上一篇:XML示例:字符串读写操作函数的程序编写
- 下一篇:十种关于 XML 的观点