- UID
- 343
- 帖子
- 987
- 精华
- 13
- 积分
- 7771
- 阅读权限
- 101
- 来自
- 哈尔滨工程大学
- 在线时间
- 124 小时
- 注册时间
- 2004-12-17
- 最后登录
- 2008-7-11
|
3楼
发表于 2007-9-5 18:28
| 只看该作者
源代码- Stage.scaleMode = "noScale";
- _root.attachMovie("LineGroup", "lg_mc", -2);
- _root.attachMovie("Ball", "ball_mc", -1);
- for (var i = 0; i<6; i++) {
- _root.attachMovie("ChangeLine", "cl"+i+"_mc", i);
- _root["cl"+i+"_mc"]._yscale=98
- }
- var k:Number = 0.1;
- var r:Number = ball_mc._width/2;
- var w:Number = Stage.width;
- var h:Number = Stage.height;
- lg_mc._x = w/2;
- lg_mc._y = h/2;
- _root.onEnterFrame = function() {
- var gx:Number = _root._xmouse;
- var gy:Number = _root._ymouse;
- var lx:Number = ball_mc._x;
- var ly:Number = ball_mc._y;
- gx = gx<r ? r : gx;
- gx = gx>(w-r) ? (w-r) : gx;
- gy = gy<r ? r : gy;
- gy = gy>(h-r) ? (h-r) : gy;
- var nx = Math.floor((lx-15)/30);
- var ny = Math.floor((ly-15)/30);
- with (cl0_mc) {
- _x = nx*30;
- _y = ly;
- _rotation = 180;
- var d = Math.floor(Math.abs(lx-_x));
- cl0_mc.gotoAndStop(d);
- }
- with (cl1_mc) {
- _x = nx*30+30;
- _y = ly;
- var d = Math.floor(lx-_x);
- if (d>0) {
- _rotation = 180;
- } else {
- _rotation = 0;
- }
- d = Math.abs(d);
- d = d == 0 ? 1 : d;
- cl1_mc.gotoAndStop(d);
- }
- with (cl2_mc) {
- _x = nx*30+60;
- _y = ly;
- _rotation = 0;
- var d = Math.floor(Math.abs(lx-_x));
- cl2_mc.gotoAndStop(d);
- }
- with (cl3_mc) {
- _x = lx;
- _y = ny*30;
- _rotation = 270;
- var d = Math.floor(Math.abs(ly-_y));
- cl3_mc.gotoAndStop(d);
- }
- with (cl4_mc) {
- _x = lx;
- _y = ny*30+30;
- var d = Math.floor(ly-_y);
- if (d>0) {
- _rotation = 270;
- } else {
- _rotation = 90;
- }
- d = Math.abs(d);
- d = d == 0 ? 1 : d;
- cl4_mc.gotoAndStop(d);
- }
- with (cl5_mc) {
- _x = lx;
- _y = ny*30+60;
- _rotation = 90;
- var d = Math.floor(Math.abs(ly-_y));
- cl5_mc.gotoAndStop(d);
- }
- ball_mc._x += (gx-lx)*k;
- ball_mc._y += (gy-ly)*k;
- };
复制代码 |
|