
Код AS3:
package {
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
private var _ball:Sprite = new Sprite();
private var _speed:Number = 10;
public function Main() {
_ball.graphics.beginFill(0xFF0000);
_ball.graphics.drawCircle(0, 0, 20);
_ball.graphics.endFill();
_ball.y = 100;
addChild(_ball);
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):void {
_ball.x += _speed;
if (_ball.x >= stage.stageWidth || _ball.x < 0) {
_speed *= -1;
}
}
}
}