Linux中国  设为主页
 收藏本站
 
当前位置: > 首页 ->网站设计 ->Flash ->用Flash AS编写蝌蚪摆尾特效动画
  相关分类: 
AJAX教程
CSS/CSS2
Dreamweaver
Fireworks
Flash
HTML/DHTML
JavaScript
Phososhop
网页制作
  站内搜索: 
热门文章排行
热门文章排行 FLASH动画制作步骤和注意事项(04-13)
FLASH的基本操作(04-13)
Flash:水波荷花(04-13)
FLASH添加声音(04-13)
Flash MX 认证考试(样题)(04-13)
精采文章排行
精采文章排行 用Flash AS编写蝌蚪摆尾特效动画(06-06)
和Flash初学者详谈Loading的制作(06-06)
Flash Actionscript知识:从AS2到AS3(06-06)
在Flash动态文本框中加载HTML格式文(06-06)
谈Flash脚本与时间轴动作的执行顺序(06-06)
  ·和Flash初学者详谈Loading的制作·Flash Actionscript知识:从AS2到AS3·在Flash动态文本框中加载HTML格式文本·谈Flash脚本与时间轴动作的执行顺序·Flash最常用AS语法及语句总结·关于 JavaScript 和 Flash 间的通信·Flash文件的加密与破解技术详细解析·透明的flash是这样制作出来的·Flash文件的破解与加密方法探秘

用Flash AS编写蝌蚪摆尾特效动画

作者:Webmaster   来源:Linuxdby.com   点击:   日期:2007-06-06 [收藏] [投稿]

  IE是否经常中毒?推荐您

  本文中我们用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 ()

  MC里的代码:

#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);

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<

上一页12 下一页

上一篇:和Flash初学者详谈Loading的制作   下一篇:没有了
文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论

   相关文章:
·用Flash AS编写蝌蚪摆尾特效动画

   文章评论:(1条)
  
 请留名: 匿名评论   点击查看所有评论 论坛讨论
 

 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。