Flash AS教程:蝌蚪摆尾动画

互联网   发布时间:2008-10-06 01:25:38   作者:佚名   我要评论
本例介绍使用Flash的AS编写蝌蚪摆尾动画效果,希望朋友们喜欢~~   先看最终效果    副标题   场景里代码   Object.environment = this;   Math.prototype.degrees = function (r)   {   return (r * 180 / 3.141593E 000)

  #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 cs6鼠标跟随效果实现代码分享

    flash cs6想要实现鼠标跟随效果?该怎么制作呢?今天我们就来看看使用as2.0实现鼠标跟随效果的教程,需要的朋友可以参考下
    2019-05-19
  • Flash cs6怎么使用代码输入中英文文本?

    Flash cs6怎么使用代码输入中英文文本?Flash cs6中可以使用文字工具直接输入文本,也可以使用代码来输入文本,该怎么使用代码输入文本呢?请看下文详细的教程,需要的朋友
    2018-03-11
  • flash as3.0怎么定义抽象类和抽象?

    flash as3.0抽象类怎么定义? as3.0中有很多抽象类,该怎么定义抽象类和抽象方法呢?下面我们就来看看简单的例子,需要的朋友可以参考下http://www.jb51.net/softs/408402.
    2018-02-28
  • flash cs6中怎么使用ActionScript3.0?

    flash cs6中怎么使用ActionScript3.0?flash cs6中想要使用ActionScript3.0功能,该怎么使用呢?下面我们就来看看详细的教程,需要的朋友可以参考下
    2018-01-25
  • Flash中怎么实现鼠标点击决定图像位置?

    本教程给大家分享一个Flash小教程,教大家在Flash CS6中怎么实现鼠标点击决定图像位置?方法很简单,感兴趣的朋友欢迎前来一起分享学习
    2018-01-12
  • Flash中如何用代码将图片放在自己想要的舞台位置?

    本教程教脚本之家的ActionScript教程学习者在Flash中如何用代码将图片放在自己想要的舞台位置,教程讲解的详细,感兴趣的朋友欢迎前来分享学习
    2017-11-20
  • 在Flash CS6中使用with函数绘制背景图教程

    本教程教脚本之家的ActionScript教程学习者如何在Flash CS6中使用with函数绘制背景图?教程一步步讲解的挺详细,方法也不难,非常适合Flash新手入门学习
    2017-11-18
  • Flash怎么设置元件坐标?flash使用代码设置元件的坐标的教程

    Flash怎么设置元件坐标?flash中导如的元件需要添加坐标,该怎么定位元件坐标呢?下面我们就来看看flash使用代码设置元件的坐标的教程,需要的朋友可以参考下
    2017-10-11
  • Flash怎么制作来回摇摆的花朵的动画?

    Flash怎么制作来回摇摆的花朵的动画?Flash中想要给花朵制作一段摇摆的动画效果,该怎么制作呢?下面我们就来看看详细的教程,很简单,需要的朋友可以参考下
    2017-05-23
  • Flash怎么制作流动七彩色的文字?

    Flash怎么制作流动七彩色的文字?想要让文字动起来,该怎么使用flash给文字制作一个流动七彩色的动画呢?下面我们就来看看详细的教程,需要的朋友可以参考下
    2017-04-23

最新评论