论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash AS教程
Tag:2.0,3.0菜鸟,游戏,,cs,技巧,源码,,文本,文字,函数,音乐,随机,拖拽,asp,access,xml,mc,视频教程

Flash AS2制作跳动的小球动画效果

文章类别:Flash AS | 发表日期:2009-12-2 10:24:21

效果显示:

详细代码:

//AS2.0  QQ:31559783   2009.11.28
MovieClip.prototype.zl = function() {
        this.vg = 0.7;
        this.vy = 0;
        this.vx = 0;
        this.an = true;
        this.onEnterFrame = function() {
                this.vy += this.vg;
                this._y += this.vy;
                this._x += this.vx;
                if (this._x>550) {
                        this._x = 0;
                }
                if (this._x<0) {
                        this._x = 550;
                }
                if (this._y>300) {
                        this._y = 300;
                        this.vy *= -0.5;
                        this.vx *= 0.9;
                }
                if (this._y == 300 && this.an == true) {
                        ss(this._x, this._y);
                }
                if (this._y == 300 && Math.abs(this.vy) >> 0 == 0) {
                        this.an = false;
                }
        };
        this.tt = function() {
                this.vg = 0.7;
                this.vy = 0;
                this.vx -= (this._x-_root._xmouse)/30;
                this.dy = this._y-_root._ymouse;
                this.vy -= this.dy/10;
        };
};
function ss(X, Y) {
        var sj = (Math.random()*10+20) >> 0;
        for (var i = 0; i<sj; i++) {
                var mc = this.createEmptyMovieClip("huaxian_mc", this.getNextHighestDepth());
                mc._x = X;
                mc._y = Y;
                mc.lineStyle(Math.random()*3, 0, 100);
                mc.moveTo(0, 0);
                mc.lineTo(1, 0);
                mc.vx = random(20)-10;
                mc.vy = random(20)-10;
                mc.onEnterFrame = function() {
                        this._x += this.vx;
                        this._y += this.vy;
                        this.vy += 0.8;
                        this._alpha -= 2;
                        if (this._alpha<1 || this._y>=300) {
                                this.removeMovieClip();
                        }
                };
        }
}
mc.zl();
mc1.zl();
this.onMouseDown = function() {
        if (mc.an == false) {
                ss(mc._x, mc._y);
                mc.an = true;
                mc.tt();
        }
};
this.onEnterFrame = function() {
        if (random(50) == 0) {
                if (mc1.an == false) {
                        ss(mc1._x, mc1._y);
                        mc1.an = true;
                        mc1.tt();
                }
        }
};

视频教程列表
文章教程搜索
 
Flash AS推荐教程
Flash AS热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058