ForceSchemaClass内容:
//铁血制作
class ForceSchemaClass extends MovieClip{//ForceSchemaClass类继承MC
[Inspectable]//元数据标记(可以出现在参数列表中)
public var f:Array;
[Inspectable]
public var theta:Array;
[Inspectable]
public var fname:Array;
public function ForceSchemaClass(){
drawLine(f,theta,fname); //调用drawLine函数画图,f,theta,fname分别
//为力的大小、力的角度(与水平向右方向的夹角)、力的名称
}
private function drawLine(f:Array,theta:Array,fname:Array):Void{//drawLine方法
var t = 0;
this.lineStyle(2, 0xFF0000, 100);
var cos = Math.cos;
var sin = Math.sin;
var PI = Math.PI;
var f =f;
var theta =theta;
this.onEnterFrame = function() {
if (t<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++;
};
};
}
源文件:
force.rar
(4.77 KB, 下载次数: 7)
|