当前位置: 首页 > 图文教程 > Flash动画 > ActionScript > Flash AS2实例 跳动的小球动画效果

ActionScript
Flash AS实例:制作切换菜单动画
Flash AS3实例教程:简单的转动的星星
Flash AS3实例教程:制作旋转的菜单动画
项目中使用发布swc时遇到两个问题
Flash AS3教程:随图片大小而动态改变的图框
Flash AS3教程:创建好看的遮罩动画效果
Flash AS3.0教程:制作老鹰飞动实例
Flash as入门(6):文本与字符串
Flash as入门(8):加载和卸载swf文件
Flash as入门(17):Math类三角函数
Flash AS3实例教程:连锁反应的粒子动画
AS3实例教程:结合基本的动画和AS3绘图API
学习AS3知识:常用的8个AS3小技巧
Flash AS3实例教程:漂亮的水纹动画
Flash AS3实现动画中音乐音量逐渐关闭
AS 3.0的TransitionManager类制作动画
AS3实例教程:制作数码下落的动画特效
AS3面试题:复杂算法的改进
AS3.0实例:鼠标感应发光的文字效果
Flex4教程:添加事件的3种方法

ActionScript 中的 Flash AS2实例 跳动的小球动画效果


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-17   浏览: 75 ::
收藏到网摘: n/a

效果显示:

详细代码:

复制代码
代码如下:

//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();
}
}
};

flv文件下载 跳跃的小球