Flash AS实现的蝌蚪摆尾动画的教程

所属分类: 媒体动画 / Flash教程 阅读数: 73
收藏 0 赞 0 分享
本例介绍使用Flash的AS编写蝌蚪摆尾动画效果,希望朋友们喜欢~~
 

 
场景里代码

复制代码
代码如下:

  Object.environment = this;
  Math.prototype.degrees = function (r)
  {
  return (r * 180 / 3.141593E+000);
  };
  maxtents = 3;
  this.onEnterFrame = function ()
  {
  if (!random(30) && tents < maxtents)
  {
  var nombre = "tent" + String(depth++);
  var neo = this.attachMovie("tentacle", nombre, depth);
  neo._x = random(600);
  neo._y = 370;
  neo.theta = 270;
  ++tents;
  } // end if
  };
  stop ()

#initclip 1

复制代码
代码如下:

  function TentacleClass()
  {
  this.numNodes = 27;
  this.head = 2 + random(4);
  this.girth = 8 + random(12);
  this.speedCoefficient = 9.000000E-002 + random(10) / 50;
  this.friction = 9.000000E-001 + random(10) / 100;
  this.muscleRange = 20 + random(50);
  this.muscleFreq = 1.000000E-001 + random(100) / 250;
  this.generateNodes();
  this.onEnterFrame = this.move;
  } // End of the function
  TentacleClass.prototype = new MovieClip();
  TentacleClass.prototype.generateNodes = function ()
  {
  this.node = new Array();
  var n = 0;
  while (n < this.numNodes)
  {
 
  var point = {x: 0, y: 0};
  this.node.push(point);
  ++n;
  } // end while
  };
  TentacleClass.prototype.move = function ()
  {
  this.tv = this.tv + 5.000000E-001 * (Math.random() - Math.random());
  this.theta = this.theta + this.tv;
  this.tv = this.tv * this.friction;
  this.node[0].x = this.head * Math.cos(1.745329E-002 * this.theta);
  this.node[0].y = this.head * Math.sin(1.745329E-002 * this.theta);
  this.count = this.count + this.muscleFreq;
  this.thetaMuscle = this.muscleRange * Math.sin(this.count);
  this.node[1].x = -this.head * Math.cos(1.745329E-002 * (this.theta + this.thetaMuscle));
  this.node[1].y = -this.head * Math.sin(1.745329E-002 * (this.theta + this.thetaMuscle));
  var i = 2;
  while (i < this.numNodes)
  {
  var dx = this.node.x - this.node[i - 2].x;
  var dy = this.node.y - this.node[i - 2].y;
  var d = Math.sqrt(dx * dx + dy * dy);
  this.node.x = this.node[i - 1].x + dx * this.girth / d;
  this.node.y = this.node[i - 1].y + dy * this.girth / d;
  if (i == 2)
  {
  this._x = this._x - dx * this.speedCoefficient;
  this._y = this._y - dy * this.speedCoefficient;
  if (this._x + this._width < 0    this._x - this._width > 600    this._y + this._height < 0    this._y - this._height > 400)
  {
  --Object.environment.tents;
  this.removeMovieClip();
  } // end if
  } // end if
  ++i;
  } // end while
  this.clear();
  this.moveTo(this.node[1].x, this.node[1].y);
  var i = 2;
  while (i < this.numNodes)
  {
  this.lineStyle(int(this.numNodes - i) * (this.numNodes - i) / 20, 16777215, 100);
  this.lineTo(this.node.x, this.node.y);
  ++i;
  } // end while
  };
  Object.registerClass("tentacle", TentacleClass);
  #endinitclip
更多精彩内容其他人还在看

ColorTransform类调整显示对象的颜色值

ColorTransform 首先,我们要知道,一个颜色由四个通道组成:红、绿、蓝和alpha通道(这个alpha通道在PS里我不知道对应哪个),他们的十六进制颜色值分别为: 红:0xffff0000       绿:0xff00ff0
收藏 0 赞 0 分享

Flash AS3 快速制作烟雾动画

Flash AS3教程:快速制作烟雾动画,由于还要上传AS不给大家看效果了,本文最后提供源码压缩包下载,本教程主要利用AS3的类来实现。首先我们在Photoshop中制作一个烟雾的照片,这里主要使用Photoshop的画笔来实现。 之后我们导入到FLASH中来,然后转变
收藏 0 赞 0 分享

Flash AS3 制作文字飞出动画

效果:   代码: [code] import gs.TweenMax; txtInfo.text="TextField 类用于创建显示对象以显示和输入文本。 SWF 文件中的所有动态文本字段和输ActionScript 提供了多种在运行时设置文本格式
收藏 0 赞 0 分享

Flash 制作晃动光线文字特效

看到网上有个很好的效果,自己学着做了一个,先看看效果演示
收藏 0 赞 0 分享

Flash 绘画技巧 投影滤镜设置阴影

这个例子我们将在它的结构中使用投影滤镜。这个技巧将提供一个很酷的方法,用相同的滤镜获得更多的层次和透视图。
收藏 0 赞 0 分享

ActionScript 学习小心得

ActionScript学习小得
收藏 0 赞 0 分享

ActionScript3.0读取网页FlashVars中的参数的问题

最近在做一个从网页读取参数的swf,以前用AS2.0可以直接读取FlashVars中的变量,但是AS3.0却无法取到。
收藏 0 赞 0 分享

Flash 视频广告的定位兼容性问题

在项目中,用到了一个Flash视频广告,但是该视频广告在Firefox中显示实在是差强人意,居然漂浮在了网站的左上角,该怎么解决这个问题呢?
收藏 0 赞 0 分享

flash 超链接问题

昨天我的朋友找我帮忙,想在他们网站的首页的flash上加一个超链接,点击后导向一个页面,我知道flash不支持click等事件,在网上搜索一下,发现几种方法,下面逐一说明一下,省的后续zz们走弯路
收藏 0 赞 0 分享

Flash AS 制作创意的鼠标经过的网页导航

鼠标经过-导航条出现;鼠标移开-导航条消失。
收藏 0 赞 0 分享
查看更多