Flash ActionScript
帧循环(EnterFrame)
代码如下:
1 //Save as BallMove.as
2 package
3 {
4 import flash.display.Sprite;
5 import flash.events.Event;
6
7 public class BallMove extends Sprite
8 {
9 private var ball:Sprite;
10
11 public function BallMove ()
12 {
13 Init ();
14 }
15 public function Init ():void
16 {
17 ball=new Sprite();
18 addChild (ball);
19
20 ball.graphics.beginFill (0xffff00);
21 ball.graphics.drawCircle (0,0,5);
22 ball.graphics.endFill ();
23
24 ball.x=stage.stageWidth/2;
25 ball.y=stage.stageHeight/2;
26
27 ball.addEventListener (Event.ENTER_FRAME,Ball_EnterFrame);
28 }
29 private function Ball_EnterFrame (e:Event):void
30 {
31 ball.x+=(15-30*Math.random());
32 ball.y+=(15-30*Math.random());
33 }
34 }
35 }
posted @
2008-12-29 09:11
HelloCG
阅读(
271)
评论()
编辑
收藏
举报