如何使用动作脚本绘制圆圈(作为组件)我尝试了一些xample不起作用....我需要在面板中添加这个圆圈
答案 0 :(得分:2)
// 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);
如果您只想要圆的外边缘,则可以替换beginLine和endLine而不是beginFill和endFill。
答案 1 :(得分:2)
组件类:
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));
}
}
面板组件:
<mx:Panel width = "400" height
= "400">
<local:MyCircle
width = "100%"
height = "100%"/>
</mx:Panel>