//隨機產生泡泡 var bubbleArea:Sprite = new Sprite(); //建立泡泡的Sprite實體 var bubbleTimer:Timer = new Timer(800, 0); bubbleTimer.addEventListener(TimerEvent.TIMER, makeBubble); function makeBubble(event:TimerEvent) { var bubble: MovieClip = new bubble_mc(); //產生x座標於 -50 (在螢幕外面) bubble.x = -50; //隨機產生y的座標,介於 20 - 380之間的高度 var yPos: int = 20 + Math.random()*360; bubble.y = yPos; //將泡泡放在舞台上 bubbleArea.addChild(bubble); } bubbleTimer.start();