//设置边界:上下左右 //var top:Number = 0; var right:Number = stage.stageWidth; //var bottom:Number = stage.stageHeight; var left:Number = 0; //设置位移:x、y 为水平和垂直轴 var vx:Number = 3; //var vy:Number = 3; //注册ENTER_FRAM事件侦听器 addEventListener(Event.ENTER_FRAME, mover); //响应函数:负责影片的整个动画 function mover(e:Event):void { ball.x += vx; //ball.y += vy; if (ball.x < left + ball.width / 2) { vx *= -1; } else if (ball.x > right - ball.width / 2) { ball.x = right - ball.width / 2; vx *= -1; } /*if (ball.y < top + ball.height / 2) { ball.y = top+ball.height / 2; vy *= -1; } else if (ball.y > bottom - ball.height / 2) { ball.y = bottom - ball.height / 2; vy *= -1; }*/ } 设置边界: |
|
来自: 宜宾翠屏区 > 《ActionScprit3.0》