第一个简单组件:用于画物理力的图示
Flash 动画:
代码:
//铁血制作
#initclip
function aaClass() {
this.drawLine(this.f, this.theta, this.fname);
}
Object.registerClass("aa", aaClass);
aaClass.prototype = new MovieClip();
aaClass.prototype.drawLine = function() {
var t = 0;
this.lineStyle(2, 0xFF0000, 100);
var cos = Math.cos;
var sin = Math.sin;
var PI = Math.PI;
var f = this.f;
var theta = this.theta;
this.onEnterFrame = function() {
if (t<this.f.length) {
this.moveTo(0, 0);
this.lineTo(f[t]*cos(theta[t]*PI/180), -f[t]*sin(theta[t]*PI/180));//力的大小
this.lineTo((f[t]-10)*cos(theta[t]*PI/180)+5*sin(theta[t]*PI/180), -(f[t]-10)*sin(theta[t]*PI/180)+5*cos(theta[t]*PI/180));//箭头的一撇
this.moveTo(f[t]*cos(theta[t]*PI/180), -f[t]*sin(theta[t]*PI/180));
this.lineTo((f[t]-10)*cos(theta[t]*PI/180)-5*sin(theta[t]*PI/180), -(f[t]-10)*sin(theta[t]*PI/180)-5*cos(theta[t]*PI/180));//箭头另一撇
this.createTextField("pos"+t, t, 0, 0, 40, 50);//力的标签
this["pos"+t]._x = f[t]*cos(theta[t]*PI/180)+5;
this["pos"+t]._y = -f[t]*sin(theta[t]*PI/180)-5;
this["pos"+t].text = this.fname[t].toString();
} else {
delete this.onEnterFrame;
}
t++;
};
};
#endinitclip
Flash 动画:
代码:
//铁血制作
#initclip
function aaClass() {
this.drawLine(this.f, this.theta, this.fname);
}
Object.registerClass("aa", aaClass);
aaClass.prototype = new MovieClip();
aaClass.prototype.drawLine = function() {
var t = 0;
this.lineStyle(2, 0xFF0000, 100);
var cos = Math.cos;
var sin = Math.sin;
var PI = Math.PI;
var f = this.f;
var theta = this.theta;
this.onEnterFrame = function() {
if (t<this.f.length) {
this.moveTo(0, 0);
this.lineTo(f[t]*cos(theta[t]*PI/180), -f[t]*sin(theta[t]*PI/180));//力的大小
this.lineTo((f[t]-10)*cos(theta[t]*PI/180)+5*sin(theta[t]*PI/180), -(f[t]-10)*sin(theta[t]*PI/180)+5*cos(theta[t]*PI/180));//箭头的一撇
this.moveTo(f[t]*cos(theta[t]*PI/180), -f[t]*sin(theta[t]*PI/180));
this.lineTo((f[t]-10)*cos(theta[t]*PI/180)-5*sin(theta[t]*PI/180), -(f[t]-10)*sin(theta[t]*PI/180)-5*cos(theta[t]*PI/180));//箭头另一撇
this.createTextField("pos"+t, t, 0, 0, 40, 50);//力的标签
this["pos"+t]._x = f[t]*cos(theta[t]*PI/180)+5;
this["pos"+t]._y = -f[t]*sin(theta[t]*PI/180)-5;
this["pos"+t].text = this.fname[t].toString();
} else {
delete this.onEnterFrame;
}
t++;
};
};
#endinitclip
回复Comments
作者:
{commentrecontent}