本站版权所有 新丁flash资源网 保留所有权利 未经许可请勿任意转载或复制使用
请使用1024*768分辨率浏览本站以达到浏览新丁flash资源网的最佳视觉效果
新丁flash资源网中所有的解压密码均为:www.qnflash.com
粤ICP备08010396号

首先制作一个小球的电影元件,只要画一个圆然后转变为电影剪辑元件就可以。电影剪辑名字叫ball。

然后在第一帧加入下面代码:
power = 0.3;
yspeed = 0;
xspeed = 0;
friction = 0.95;
_root.attachMovie("ball", "ball", 1, {_x:250, _y:175});
ball.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
if (Key.isDown(Key.UP)) {
yspeed -= power
}
if (Key.isDown(Key.DOWN)) {
yspeed += power
}
xspeed *= friction;
this._y += yspeed;
this._x += xspeed;
};
效果如下:(按键盘方向键可以看到效果)
给小球来个渐变填充,象一个球了!呵呵
再来个阴影。
下面我们再给引入一幅材质图案,库面板如下:

效果如下:
然后利用ActionScript加上遮照。主要是利用mc.setMask()函数设置遮照了!
power = 0.3;
yspeed = 0;
xspeed = 0;
friction = 0.95;
_root.attachMovie("ball", "ball", 1, {_x:250, _y:175});
ball.texture.setMask(ball.ball_itself);
ball.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
if (Key.isDown(Key.UP)) {
yspeed -= power
}
if (Key.isDown(Key.DOWN)) {
yspeed += power
}
xspeed *= friction;
this._y += yspeed;
this._x += xspeed;
};
效果如下:
然后我们让该球真的滚动起来,滚动的更加真实。
power = 0.3;
yspeed = 0;
xspeed = 0;
friction = 0.95;
_root.attachMovie("ball", "ball", 1, {_x:250, _y:175});
ball.texture.setMask(ball.ball_itself);
ball.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
if (Key.isDown(Key.UP)) {
yspeed -= power;
}
if (Key.isDown(Key.DOWN)) {
yspeed += power;
}
xspeed *= friction;
yspeed *= friction;
this._y += yspeed;
this._x += xspeed;
this.texture._y += yspeed;
this.texture._x += xspeed;
if (this.texture._x>158) {
this.texture._x -= 188;
}
if (this.texture._x<-158) {
this.texture._x += 188;
}
if (this.texture._y>158) {
this.texture._y -= 188;
}
if (this.texture._y<-158) {
this.texture._y += 188;
}
};
效果如下:
下面是另外一种材质制作的动画。
最后把上面的7个演示动画的源文件提供给大家:点击这里下载源文件