it技术指南:www.itedus.com
  • 信息订阅

IT指南

  • TNT五分钟问卷赢IPOD
  • 贝塔斯曼
  • 广告联盟
  • No pay, More gain!
  • 单价15元-网络广告平台
  • 注册阿里妈妈赚广告费
  • 首页
  • 新闻资讯
  • 网页制作
  • 软件使用
  • 操作系统
  • 软件编程
  • 网络编程
  • 图象处理
  • 网站欣赏
  • 数据库
  • 认证考试
  • 站长知识
正在浏览栏目导航:首页 > 图象处理 > Flash >

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

时间:2007-11-29 16:33:35   来源:本站原创  作者:IT爱好者

  本文中我们用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);
#endinitclip

关键字:
关闭此页
上一篇:和Flash初学者详谈Loading的制作
下一篇:用Flash轻松制作鼠标点击发散特效动画

相关文章

    无相关信息
本栏目推荐
  • 格斗动画在Flash中的

排行榜

  • 1格斗动画在Flash中的应用
  • 2Flash中有关层的深度处理的常用函数
  • 3Flash AS动画实例:风吹云飘草动
  • 4Flash AS代码制作鼠标触发图片缓冲放缩
  • 5Flash加载外部文件的各种方法与技巧
  • 6Flash片头loading与MovieClipLoader
  • 7Flash片头加载loading的基础讨论
  • 8Flash完美的loading-吐血整理!

最新信息

  • 格斗动画在Flash中的应用
  • 把按钮藏起来 谈制作Flash课件时的隐形
  • 用Flash制作Google搜索程序
  • 教您一招:为Flash MX打造一个完美的共
  • Flash MX精彩实例:制作给物体堆雪的效
  • Flash实例精通:教你制作交互式二合一按
  • 丰富多彩 有声有色的Flash互动动画世界
  • Flash实例精通:教你制作马赛克效果
关于站点 - 广告服务 - 联系我们 - 返回顶部
Copyright © 2007 www.itedus.com . All rights reserved.QQ群:8814225
如果碰到相关技术问题可以联系我们,原创相关问题请与站长及时联系.鄂ICP备07005792号