Flash AS教程:蝌蚪摆尾动画

所属分类: 媒体动画 / Flash教程 阅读数: 87
收藏 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
更多精彩内容其他人还在看

flash怎么制作镜像动画?

flash怎么制作镜像动画?flash中制作动画很简单,怎么才能制作一个动画的镜像呢?下面我们就来看看flash制作镜像动画的详细教程,很简单,需要的朋友可以参考下
收藏 0 赞 0 分享

flash制作图片变换的gif动画效果

这篇教程是向脚本之家的朋友分享flash制作图片变换的gif动画效果方法,教程制作出来的动画效果非常不错,难度不是很大,一起来学习吧
收藏 0 赞 0 分享

flash怎么绘制和谐号火车从火车道开过的动画?

flash怎么绘制和谐号火车从火车道开过的动画?想制作一个火车从轨道上飞奔而过的一个画面,该怎么制作呢?下面我们就来看看flash制作和谐号火车从火车道开过的动画的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

FLASH怎么制作红烛燃烧的动画?

FLASH怎么制作红烛燃烧的动画?FLASH中做动画很方便,今天我们就来看看使用flash制作蜡烛燃烧并流下烛蜡的教程,很简单,下面我们就来看看详细教程,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么填充渐变色? flash渐变填充的使用方法

flash怎么填充渐变?flash中想给图形添加渐变色,该怎么添加呢?下面我们就来看看flash渐变填充的使用方法,这是基础教程,很简单,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么制作磁铁吸钉子的动画?

flash怎么制作磁铁吸钉子的动画?我们知道钉子放到磁铁周围就会直接将钉子吸走,该怎么制作这个动画呢?下面我们就来看看flash制作磁铁吸引钉子的动画教程,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么画中国国宝大熊猫? flash绘制卡通大熊猫的教材

flash怎么画中国国宝大熊猫?flash中制作动画很简单,但是也可以简单的绘制图形,该怎么绘制呢?今天我们就来看看flash绘制卡通大熊猫的教材,需要的朋友可以参考下
收藏 0 赞 0 分享

Flash工具缩放、旋转和倾斜对象使用介绍

今天小编为大家介绍Flash工具缩放、旋转和倾斜对象使用方法,对于初学者来说,是个很好的学习教程,推荐到脚本之家,一起来看看吧
收藏 0 赞 0 分享

flash中怎么用鼠标绘制一朵木兰花?

flash中怎么用鼠标绘制一朵木兰花?flash中除了做动画效果以外,还可以绘制图形,今天我们就来看看flash用鼠标绘制一朵木兰花的详细教程,很简单,详细教程请看下文
收藏 0 赞 0 分享

FLASH制作一个小车一直往前推的动画?

FLASH制作一个小车一直往前推的动画?想做一个动画,就是有个小推车一直不断的往前进,中途不能倒,该怎么制作呢?下面我们就来看看这个动画的制作方法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多