复制内容到剪贴板
代码:
var ball:Sprite = new Sprite();
addChild(ball);
ball.graphics.beginFill(0);
ball.graphics.drawCircle(0, 0, 30);
ball.y = stage.stageHeight/2;
ball.x = stage.stageWidth/2;
var vx:Number = 5;
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event):void {
ball.x += vx;
if (ball.x - ball.width/2 < 0) {
ball.x = ball.width/2;
vx *= -1;
} else if (ball.x + ball.width/2 > stage.stageWidth) {
ball.x = stage.stageWidth - ball.width/2;
vx *= -1;
}
}