Flex the string or number shown in the figure above. Mainly using TestField.

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
package  
{
    import flash.text.TextFormatAlign;	
    import flash.text.TextField;	
    import flash.display.Sprite;
    import flash.text.TextFormat;	

    public class LabeledCircle extends Sprite 
    {
    	private var textField:TextField;

    	public function LabeledCircle(radius:Number, label:String = "")
    	{
    		// Prepares the textField

    		var textFormat:TextFormat = new TextFormat();
    		textFormat.align = TextFormatAlign.CENTER;

    		textField = new TextField();
    		textField.defaultTextFormat = textFormat;

    		addChild(textField);

    		// Sets the default parameters

    		this.radius = radius;
    		this.label = label;
    	}


    	public function set radius(radius:Number):void
    	{
    		// redraws the circle
    		graphics.clear();
    		graphics.beginFill(0x000000, .5);
    		graphics.drawCircle(0, 0, radius);

    		// recenters the textfield depending on the radius
    		textField.width = radius * 2;
    		textField.x = -radius;
    	}


    	public function set label(label:String):void
    	{
    		textField.text = label;
    	}
    }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Victor at December 02, 2013 - 12:18 PM