请各路神仙帮忙解释flash代码意思,越详细越好,谢谢啦

来源:百度知道 编辑:UC知道 时间:2024/06/04 10:36:55
number_of_balls =8;
for (x=1; x<=number_of_balls; x++) {
ball = attachMovie("ball", "ball_"+x, _root.getNextHighestDepth(), {_x:Math.random()*400-50, _y:Math.random()*300-50});
ball.collision = 0;
ball.mass = 1;
ball.xspeed = Math.random()*8-4;
ball.yspeed = Math.random()*8-4;
ball.onEnterFrame = function() {
else if (this._x>485) {
this._x = 485;
this.xspeed *= -1;
if (this._y<15) {
this._y = 15;
this.yspeed *= -1;
if (this.xspeed>speed_limit) {
this.xspeed = speed_limit;
if (this.xspeed<speed_limit*-1) {
this.xspeed = speed_limit*-1;
this._x += this.xspeed;
this._y += this.yspeed;
function manage_bounce(ball, ball2) {
dx = ball._x-ball2._x;
dy = ball._y-ball2._y;
collisionision_angle = Math.atan2(dy, dx);
magnitude_1 = Math.sqrt(ball.xspeed*ball.xspeed+ball.yspeed*ball.yspeed);
magnit

number_of_balls = 8;
//球的个数8个
//speed_limit = 10;
for (x=1; x<=number_of_balls; x++) {
ball = attachMovie("ball", "ball_"+x, _root.getNextHighestDepth(), {_x:Math.random()*400-50, _y:Math.random()*300-50});
//从库中元件链接标识符为“ball”的元件,贴8次
//getNextHighestDepth()这个深度值是从0开始,顺序递增到“影片剪辑数目-1”,
ball.collision = 0;
//collision碰撞;相撞
ball.xspeed = Math.random()*18-4;
ball.yspeed = Math.random()*18-4;
//yspeed y方向的速度
ball.onEnterFrame = function() {
if (this._x<0) {
this._x = 0;
this.xspeed *= -1;
//到x>485边上反向
}
if (this._y<0) {
this._y = 0;
this.yspeed *= -1;
//到y<15边上反向
}
if (this._x>550) {
this._x = 550;
this.xspeed *= -1;
//到x>485边上反向
}
if (this._y>400) {
this._y = 400;
this.yspeed *= -1;
//到y<15边上反向
}
if (this.xspeed>sp