网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 手机学院 | 邮件系统 | 网络安全 | 认证考试
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 图形图象 > Flash教程
图形图象:Photoshop,Fireworks,CorelDraw,Flash,3Dmax,AutoCad,Maya,Director,Authorware,Illustrator,相关软件
本月文章推荐
.也谈Flash MX中的[连接影片]功能.
.和Flash初学者详谈Loading的制作.
.让 Flash 广告具有记忆功能.
.Flash加载外部文件的各种方法与技.
.Adobe发布Flash Player 10英文版.
.Flash特效动画制作:飞舞的螺炫.
.网页中插入透明Flash的方法和技巧.
.用Flash AS代码制作按钮弹出窗口.
.Flash动态缓冲图片导航制作详解.
.精简Flash文件体积七法.
.Flash AS入门教程第六课:文本与.
.谈Flash脚本与时间轴动作的执行顺.
.将swf文件转成可自动播放的exe文.
.Adobe Flash 2006发展趋势预测.
.Flash AS代码实例:仿贝塞尔曲线.
.在Flash动态文本框中加载HTML格式.
.Flash Lite 2让移动设备轻松浏览.
.Flash教程:AS制作美丽爱心效果动.
.Profiler Agent导致的安全沙箱冲.
.Flash教程:送给初学者的一点使用.

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

发表日期:2007-5-19

  本文中我们用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的制作 人气:5562
下一篇:有关Flash ActionScript3编程的总结 人气:3793
浏览全部Flash的内容 Dreamweaver插件下载 网页广告代码 2009年新年快乐