素材图片酷 图酷镜像二 | 壁纸酷 壁纸镜像二 | 写真扫图酷 | Free Wallpaper | 贴图论坛 | ·设为首页 ·加入收藏
您现在的位置: 图酷 >> 自习室 >> 多媒体制作 >> Flash >> FLASH特效 >> 教程正文

  没有公告


仿屏保的折线 曲线运动效果
作者: 独自行走
教程来源: 闪吧
教程等级:         ★★★
教程录入: 烤焦面包
教程审核: 烤焦面包
添加时间: 2006-7-17
点击次数:
字体选择: 【字体:
相关操作: 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
热门信息:
推荐内容:

新建一MC元件,在MC的时间轴上写入下面的代码:
this._x = this._y = 0; 
total = 5; 
myColor = random(0xffffff); 
speed = 5; 
for (i = 0; i < total; i++) { 
 createEmptyMovieClip("mc" + i, i); 
 this["mc" + i]._y = random(Stage.height); 
 this["mc" + i]._x = random(Stage.width); 
 this["mc" + i].xsp = random(speed) + 5; 
 this["mc" + i].ysp = random(speed) + 5; 

onEnterFrame = function () { 
 r = Math.floor(random(5)); 
 g = Math.floor(random(10)); 
 b = Math.floor(random(20)); 
 //myColor += r << 32 + g << 16 + b; 
 //myColor &= 0xffffff; 
 for (i = 0; i < total; i++) { 
  with (this["mc" + i]) { 
   _x = _x + xsp; 
   _y = _y + ysp; 
   if (_x > Stage.width || _x < 0) { 
    xsp = -xsp; 
    myColor += r << 32 + g << 16 + b; 
    myColor &= 0xffffff; 
   } 
   if (_y > Stage.height || _y < 0) { 
    ysp = -ysp; 
    myColor += r << 32 + g << 16 + b; 
    myColor &= 0xffffff; 
   } 
  } 
 } 
 createEmptyMovieClip("xian", 100); 
 with (xian) { 
  lineStyle(2, myColor, 100); 
  start_pt_x = (mc0._x + this["mc" + (total - 1)]._x) / 2; 
  start_pt_y = (mc0._y + this["mc" + (total - 1)]._y) / 2; 
  moveTo(start_pt_x, start_pt_y); 
  for (i = 0; i < total - 1; i++) { 
   ctl_pt_x = this["mc" + i]._x; 
   ctl_pt_y = this["mc" + i]._y; 
   end_pt_x = (this["mc" + (i + 1)]._x + this["mc" + i]._x) / 2; 
   end_pt_y = (this["mc" + (i + 1)]._y + this["mc" + i]._y) / 2; 
   curveTo(ctl_pt_x, ctl_pt_y, end_pt_x, end_pt_y); 
  } 
  ctl_pt_x = this["mc" + (total - 1)]._x; 
  ctl_pt_y = this["mc" + (total - 1)]._y; 
  end_pt_x = (this["mc0"]._x + this["mc" + (total - 1)]._x) / 2; 
  end_pt_y = (this["mc0"]._y + this["mc" + (total - 1)]._y) / 2; 
  curveTo(ctl_pt_x, ctl_pt_y, end_pt_x, end_pt_y); 
 } 
}; 
在主场景中拖入三个该元件,效果如下:
/Upload/2006-07/3_131.swf
绘制折线的代码如下:
this._x = this._y = 0; 
total = 6; 
myColor = random(0xffffff); 
speed = 5; 
for (i = 0; i < total; i++) { 
 createEmptyMovieClip("mc" + i, i); 
 this["mc" + i]._y = random(Stage.height); 
 this["mc" + i]._x = random(Stage.width); 
 this["mc" + i].xsp = random(speed) + 5; 
 this["mc" + i].ysp = random(speed) + 5; 

onEnterFrame = function () { 
 r = Math.floor(random(5)); 
 g = Math.floor(random(10)); 
 b = Math.floor(random(20)); 
 //myColor += r << 32 + g << 16 + b; 
 //myColor &= 0xffffff; 
 for (i = 0; i < total; i++) { 
  with (this["mc" + i]) { 
   _x = _x + xsp; 
   _y = _y + ysp; 
   if (_x > Stage.width || _x < 0) { 
    xsp = -xsp; 
    myColor += r << 32 + g << 16 + b; 
    myColor &= 0xffffff; 
   } 
   if (_y > Stage.height || _y < 0) { 
    ysp = -ysp; 
    myColor += r << 32 + g << 16 + b; 
    myColor &= 0xffffff; 
   } 
  } 
 } 
 createEmptyMovieClip("xian", 100); 
 with (xian) { 
  lineStyle(2, myColor, 100); 
  moveTo(mc0._x, mc0._y); 
  for (i = 0; i < total -1 ; i++) { 
   lineTo(this["mc" + i]._x, this["mc" + i]._y); 
  } 
  lineTo(mc0._x, mc0._y); 
 } 
}; 

效果如下:

upload/2006-07/3_621.swf

欢迎访问我的博客 http://dzxz.blog.5d.cn

 

  • 上一篇教程:
  • 下一篇教程:
  • ::版权和投稿说明::
    • 任何媒体、网站或个人转载、链接、转贴或以其他方式复制发表本站文章,在使用时务必注明“稿件来源:图酷”及“www.tucoo.com”字样,多谢。
    • 本站已注明“来源”的文章均为转载稿,本站转载出于传递更多信息之目的。如本站转载稿涉及版权等问题,请来信与本站联系。
    • 如果您有自己原创的作品,请向我们投稿哦!您可以通过Email:gogocat@21cn.com投出自己的作品,赶快行动吧!
    • 如果觉得我们的资源有用,请推荐给朋友,谢谢!
    ::相关教程::
    纯ActionScript的Loading效果四例
    响应鼠标的图片淡入淡出效果
    用Vector类作仿3D的flash动画
    一个彩色光条的效果
    FE 粒子系统LE(冒烟)
    点点萤火虫
    降噪效果
    海浪效果教程
     
    网友评论:(评论内容只代表网友观点,与本站立场无关!) 发表评论