首页  韩国资源  酷站加油  我的展厅  设计名站  古典元素  推荐下载  设计欣赏  每周专访  招募精英  人才专区  网页教程  平面设计  编程开发  设计竞赛
当前位置:首页 > 网页教程 > Flash教程 > 正文
Google
用AS制作随机裂变的圆
来源:闪吧 作者:终极讨厌 2007年12月11日 15:21 网友评论:0条 点击:
随机裂变的圆,双击裂变,单击可以拖动...

/UploadTeach/200712/20071210171957156.swf

as:
//-------------------------------------
//flash023(终极讨厌)纯AS练习  htp://www.flash023.cn
this.createTextField("_txt", 1, 10, 36, 530, 50);
this._txt.html = true;
this._txt.htmlText = "<a href=’asfunction:geturl_func’><font color=’#ff9900’ size=’18’>flash023纯AS练习 《双击产生树形变化》 http://www.flash023.cn</font></a>";
function geturl_func() {
getURL("http://www.flash023.cn");
}
//-------------------------------------
import flash.filters.DropShadowFilter;
var filter:DropShadowFilter = new DropShadowFilter(6, 45, 0x66ff66, 50, 5, 5, 1, 2, false, false, false);
//==================初始化MC=================
this.createEmptyMovieClip("_mc", 2);
this._mc.lineStyle(30, 0x005550);
this._mc.lineTo(0, 1);
this._mc._x = 260;
this._mc._y = 200;
this._mc.xpos = 260;
this._mc.ypos = 200;
this._mc.id = 0;
this._mc.filters = [filter];
var color:Color = new Color("_mc");
color.setRGB(0xff0000);
this._mc.depth_array = [];
var cur_mc:MovieClip = this._mc;
//==================按钮事件=================
function btn_func(_mc:MovieClip) {
_mc.double = false;
_mc.onRelease = function() {
  this.double = true;
  clearInterval(time);
  var time:Number = setTimeout(function () {
   _mc.double = false;
  }, 100);
};
_mc.onPress = function() {
  //双击
  if (this.double && !this.ping) {
   cur_mc = this;
   copy_func();
   cur_mc = null;
  } else {
   //单击
   this.startDrag();
   //相关的线条重新绘制
   if (this.depth_array.length>0) {
    this.onMouseMove = draw_func;
   }
   this.onMouseUp = function() {
    this.stopDrag();
    this.draw_func = draw_func;
     this.onEnterFrame = function() {
     this._x = (this.xpos-this._x)*.3
     this._y = (this.ypos-this._y)*.3;
          this.draw_func();
     if (Math.abs(this.xpos-this._x)<1 && Math.abs(this.ypos-this._y)<1 ) {
      delete this.onEnterFrame;
     }
    };
    delete this.onMouseMove;
    delete this.onMouseUp;
   };
  }
};
}
btn_func(_mc);
//重绘线条函数
function draw_func() {
for (var p:Number = this.depth_array.length-1; p>=0; p--) {
  this._parent["line_mc"+this.depth_array[p]].clear();
  this._parent["line_mc"+this.depth_array[p]].lineStyle(1, 0xff00ff);
  this._parent["line_mc"+this.depth_array[p]].moveTo(this._parent["line_mc"+this.depth_array[p]].begin_mc._x, this._parent["line_mc"+this.depth_array[p]].begin_mc._y);
  this._parent["line_mc"+this.depth_array[p]].lineTo(this._parent["line_mc"+this.depth_array[p]].end_mc._x, this._parent["line_mc"+this.depth_array[p]].end_mc._y);
}
}
//==================复制MC=================
var depth:Number = 3000;
function copy_func() {
var color_num:Number = Math.floor(Math.random()*0xffffff);
var r_num:Number = Math.floor(Math.random()*5)+5;
for (var d:Number = r_num; d>0; d--) {
  var r:Number = Math.PI*2/r_num*d;
  var scale:Number = 90-5*cur_mc.id;
  cur_mc.ping = true;
  cur_mc.duplicateMovieClip("_mc"+depth, depth, {_xscale:scale, _yscale:scale});
  this["_mc"+depth].xpos = cur_mc._x+Math.cos(r)*scale;
  this["_mc"+depth].ypos = cur_mc._y+Math.sin(r)*scale;
  this["_mc"+depth].id = cur_mc.id+1;
  var color:Color = new Color("_mc"+depth);
  color.setRGB(color_num);
  this["_mc"+depth].filters = [filter];
  this["_mc"+depth].depth_array = [depth];
  cur_mc.depth_array.push(depth);
  btn_func(this["_mc"+depth]);
  this.createEmptyMovieClip("line_mc"+depth, 3000-depth);
  this["line_mc"+depth].begin_mc = cur_mc;
  this["line_mc"+depth].end_mc = this["_mc"+depth];
  this["_mc"+depth].onEnterFrame = function() {
   this._x += (this.xpos-this._x)*.3;
   this._y += (this.ypos-this._y)*.3;
   this._parent["line_mc"+this.depth_array[0]].clear();
   this._parent["line_mc"+this.depth_array[0]].lineStyle(1, 0xff00ff);
   this._parent["line_mc"+this.depth_array[0]].moveTo(this._parent["line_mc"+this.depth_array[0]].begin_mc._x, this._parent["line_mc"+this.depth_array[0]].begin_mc._y);
   this._parent["line_mc"+this.depth_array[0]].lineTo(this._x, this._y);
   if (Math.abs(this.xpos-this._x)<1 && Math.abs(this.ypos-this._y)<1) {
    delete this.onEnterFrame;
   }
  };
  depth++;
}
}
上一篇:实例:用控制杆实现瓢虫移动   下一篇:通过实例学习AS3.0(六)
收藏此页】【打印】【关闭
 相关文章  我要点评
·FLASH小游戏开发 第七节
·Javascript"篱式"条件判断
·让"Flash" 写文件(AS3)
·渐退方格效果(AS3)
·BitmapData与Matrix类打造超酷逼真水波效果
·AS3文档类中Loading的写法
·Smashy主题图标png
·flash中图形位置的半像素渲染问题

免责声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。对本文有任何异议,请联络:68design#163.com
转载要求:作者及来源信息必需保留。转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印。



关于我们 | 在线反馈 | 广告报价 | 友情链接 | 联系我们 | 免责声明 | 在线投稿 | 网站地图
Copyright © 2003-2007 68design.net, All Rights Reserve 【找网页设计师,当然上网页设计师联盟】