注册
 找回密码
 注册
江西广告网
查看: 181|回复: 0
打印 上一主题 下一主题

Flash5 画任意直线教程

[复制链接]

该用户从未签到

1
跳转到指定楼层
发表于 2009-1-2 11:29:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
Flash5 画任意直线教程 第一步:新建一个flash,并且建立一个mc(命名为line),并在library里输出为line mc里面是长度为100的水平直线(一定是极细线),中心坐标是(50,0) 第二步:建立连线基础类,并且建立几个设置的成员函数,具体程序如下,请放在要画线的场景或mc的第一帧里,并单独放在一个名为class的层里,action如下: function New_line(c_line) { this.c_line=c_line; } New_line.prototype.attach_line=function(c_deep) { this.deep=c_deep 0; attachMovie(this.c_line,this.c_line this.deep,this.deep); return c_deep; }; New_line.prototype.set_xy=function(c_x,c_y) { eval(this.c_line this.deep)._x=c_x; eval(this.c_line this.deep)._y=c_y; }; New_line.prototype.set_width=function(c_dx,c_dy) { this.dx=c_dx; this.dy=c_dy; this.l=Math.sqrt(this.dx*this.dx this.dy*this.dy); eval(this.c_line this.deep)._width=this.l; }; New_line.prototype.set_angle=function() { this.angle=180*Math.atan(this.dx/this.dy)/Math.PI; if(this.dy>=0) this.angle =180; eval(this.c_line this.deep)._rotation=90-this.angle; }; New_line.prototype.set_color=function(c_color) { this.mycolor=new Color(this.c_line this.deep); this.mycolor.setRGB(c_color); }; New_line.prototype.delete_line=function(c_object) { removeMovieClip(this.c_line this.deep); delete eval(c_object); } 第三步:建立实现连线函数,放在class层的下层,命名为function的层里,具体action如下: function line(c_x1,c_y1,c_x2,c_y2,c_color){ this.myline=new New_line("line"); deep=this.myline.attach_line(deep); this.myline.set_xy(c_x1,c_y1); this.myline.set_width(c_x1-c_x2,c_y1-c_y2); this.myline.set_angle(); this.myline.set_color(c_color); } line.prototype.delete_line=function(c_object) { this.myline.delete_line("myline"); delete eval(c_object); } 第四步:连线程序的具体用法。它的用法的具体形式如下: myline = new line(x1,y1,x2,y2,color); 其中x1,y1为画线起始点的坐标,x2,y2为画线中止的坐标,color为所画线的颜色具体形式为#0000FF等十六进制数,也可以用十进制,但不容易看出颜色值。 删除这条线: myline.delete_line("myline"); 用法举例:在class与function层的下面建立一action层,并且设置两个关键帧 第一帧的action是: this["myline" i]=new line(i,-50*Math.sin(i/20),i 4,-50*Math.sin((i 4)/20),0xFF00FF); if(i>=500){ for(i;i>0;i--) this["myline" i].delete_line("myline" i); } i =4; if(ip!=1){ ip=1 myline = new line(0,0,500,0); } 第二帧的action是: gotoAndPlay(_currentframe -1); 这样你就能画出一条标准的正弦曲线了 源文件下载:http://www.blueidea.com/user/goldgoat/line.fla 以上这就是我在工作中总结出来得画线程序,非常有用,而且用法也非常方便,我曾经用它做过很多优秀得作品,它最大得特点是不必考虑线得深度问题,而且删除也很方便,相信你一见就会爱不释手得。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表