<
紫色光传播网
关于我们 | 会员登陆 | 本站服务项目 | 收藏本站 | 留 言 薄
联系方式:QQ:276016898 电话:(0773)-2182627 (0)13507730004 EMAIL:wa#wahaha8.com
 | 服务项目 | 建站知识 | 网站首页 | 资源下载 | 访客留言 | 代理商城 | 网络编程 | 网页制作 | 视屏测试 | 
热门搜索关键字: 模板 | 错误 | 标签 | 采集 | 数据库 | 组件 | 代码 | 特效 | 木马 | 插件 | 虚拟主机
wahaha8.com baidu
栏目导航  
栏目更新推荐  
·Flash基础:了解动画基础知识
·使用Flash引导线制作雪花飘飘动画
·Flash中有关层的深度处理的常用函数
·用Flash AS编写蝌蚪摆尾特效动画
·FLASH制作 瀑布动画
·Flash入门:详谈Loading的制作
·Flash Actionscript知识:从AS2到A
·用Flash制作动态放大镜画面效果
点击TOP(10)  
  • 此栏目下没有热点文章
  • 图片文章  

    Flash基础:了解动画

    使用Flash引导线制作
     
    您现在的位置: 紫色光传播 >> 网页制作 >> Flash教程 >> 正文
    用Flash AS编写蝌蚪摆尾特效动画
    http://www.wahaha8.com 文章来源:www.zsgsoft.cn 点击数: 更新时间:2007-11-10 【字体:



    发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

    本文中我们用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.x = -this.head * Math.cos(1.745329E-002 * (this.theta + this.thetaMuscle));
        this.node.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.x, this.node.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

    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明
    Copyright 2006-2008 Wahaha8.com, all rights reserved. Designed by wahaha8.com
    桂ICP备05011060号