开发者

how to draw a circle using ActionScript

how to draw a circle using action script (as a comp开发者_StackOverflowonent) i tried some xample did not work....i need to add this circle in a panel


  1. Create a class derived from UIComponent
  2. Override the updateDisplayList() method inside your component and draw the circle
  3. Add an instance of your component in the panel;

Component class:

class MyCircle extends UIComponent
{
   public function MyCircle()
   {
      super();
   }

   override protected function updateDisplayList(width:Number, height:Number):void
   {
      super.updateDisplaylist(width,height);

      this.graphics.clear();
      this.graphics.beginFill(0xff0000);
      this.graphics.drawCircle(width/2, height/2, Math.min(width/2,height/2));
   }     
}

Panel component:

<mx:Panel   width    = "400"   height 
= "400">

  <local:MyCircle
     width    = "100%"
     height   = "100%"/>   

</mx:Panel>


// Draw a simple circle, gray, with a radius of 24 px

var circleColor:uint = 0xCCCCCC;
var radius:uint = 24;
var circle:Shape = new Shape();
circle.graphics.beginFill(circleColor);
circle.graphics.drawCircle(radius, radius, radius);
circle.graphics.endFill();
addChild(circle);

You can substitute beginLine and endLine instead of beginFill and endFill if you just want the circle's outer edge.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜