5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:山东
性别:先生
最后登录:2011-01-05
http://xbzg.5d.cn/
专注于Flash+FMS开发...通过Google搜索西部之光Software
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/07/15 | “波的叠加”组件用到的2.0版本的AS
类别(Flash)
|
评论
(0)
|
阅读(189)
|
发表于 17:25
class wave_add extends MovieClip {
public var n:Number;
public var Left_start:Number;
public var Right_start:Number;
public var Length_left:Number;
public var Length_right:Number;
public var tmp_Length_left:Number;
public var tmp_Length_right:Number;
public var Height_left:Number;
public var Height_right:Number;
public var Wave_left:Number;
public var Wave_right:Number;
public var i:Number;
public var ratio:Number;
public var t:Number;
public var dot:MovieClip;
public var Dot_visible:Boolean;
public var Line_visible:Boolean;
[Inspectable(defaultvalue=100)]
public function set 质点个数(num:Number):Void {
n = num;
}
public function get 质点个数():Number {
return n;
}
[Inspectable(defaultvalue=30)]
public function set 左波长(num:Number):Void {
Length_left = num;
}
public function get 左波长():Number {
return Length_left;
}
[Inspectable(defaultvalue=30)]
public function set 右波长(num:Number):Void {
Length_right = num;
}
public function get 右波长():Number {
return Length_right;
}
[Inspectable(defaultvalue=30)]
public function set 左振幅(num:Number):Void {
Height_left = num;
}
public function get 左振幅():Number {
return Height_left;
}
[Inspectable(defaultvalue=30)]
public function set 右振幅(num:Number):Void {
Height_right = num;
}
public function get 右振幅():Number {
return Height_right;
}
[Inspectable(defaultvalue=1)]
public function set 左频率(num:Number):Void {
Wave_left = num*Math.PI/Length_left;
}
public function get 左频率():Number {
return Wave_left;
}
[Inspectable(defaultvalue=1)]
public function set 右频率(num:Number):Void {
Wave_right = num*Math.PI/Length_right;
}
public function get 右频率():Number {
return Wave_right;
}
[Inspectable(enumeration="1,0"defaultvalue=1)]
public function set 质点可见(num:Boolean):Void {
Dot_visible = num;
}
public function get 质点可见():Boolean {
return Dot_visible;
}
[Inspectable(enumeration="1,0"defaultvalue=1)]
public function set 连线可见(num:Boolean):Void {
Line_visible = num;
}
public function get 连线可见():Boolean {
return Line_visible;
}
function wave_add() {
tmp_Length_left = Length_left;
tmp_Length_right = Length_right;
init();
}
function init() {
this.clear();
Left_start = 0;
//左起点
Right_start = n-1;
//右起点
for (var i = 0; i<201; i++) {
eval("this.mc"+i).removeMovieClip();
}
for (var i = 0; i<n; i++) {
this.attachMovie("mc", "mc"+i, i);
eval("this.mc"+i)._x = i*eval("this.mc"+i)._width;
eval("this.mc"+i)._y = 0;
eval("this.mc"+i)._visible = Dot_visible;
}
//判断左波长是否改变
onEnterFrame = function () {
trace("ok");
// 当左右波长改变时,相应的频率也要改变
if (tmp_Length_left<>Length_left) {
Wave_left = (Wave_left*tmp_Length_left)/Length_left;
tmp_Length_left = Length_left;
}
if (tmp_Length_right<>Length_right) {
Wave_right = (Wave_right*tmp_Length_right)/Length_right;
tmp_Length_right = Length_right;
}
};
}
function startMove() {
this.onEnterFrame = function() {
if (Line_visible == 1) {
this.createEmptyMovieClip("dot", 1000);
clear();
with (this.dot) {
moveTo(this.mc0._x, this.mc0._y);
for (var i = 0; i<this.n; i++) {
lineStyle(1, 0xff0000, 100);
lineTo(eval("this.mc"+i)._x, eval("this.mc"+i)._y);
}
}
}
t = 0;
for (i=Left_start-Length_left+1; i<=Left_start; i++) {
eval("this.mc"+i)._y += Height_left*(Math.sin(Wave_left*(t+1))-Math.sin(Wave_left*t));
t++;
}
Left_start++;
t = 0;
for (i=Right_start+Length_right-1; i>=Right_start; i--) {
eval("this.mc"+i)._y += Height_right*(Math.sin(Wave_right*(t+1))-Math.sin(Wave_right*t));
t++;
}
Right_start--;
};
}
}
0
评论
Comments
日志分类
首页
[186]
Flash
[84]
FMS
[41]
AIR
[2]
ASP
[11]
作品区
[12]
其他
[36]