模拟抛硬币 Simulating a Coin Toss

private var _field:TextField;
  
  public function flashtest()
  {
   _field = new TextField();
   _field.autoSize = "left";
   addChild(_field);
   var circle:Sprite = new Sprite();
   circle.graphics.beginFill(0,100);
   circle.graphics.drawCircle(100,100,100);
   circle.graphics.endFill();
   circle.addEventListener(MouseEvent.CLICK,onClick);
   addChild(circle);
  }
  
  private function onClick(event:MouseEvent):void
  {
   var randomNumber:Number = NumberUtilities.random(0,1);
   _field.text = (randomNumber == 0)?"heads":"tails";
  }
posted @ 2011-03-10 10:36  Lester Programming  Views(172)  Comments(0Edit  收藏  举报