views:

2407

answers:

4

Hi , I am flex newbie , so please forgive me if i am not using the right words to ask the following question. I want to know if there is a way to draw a circle which shows a number , like for ex. Graduated Circles representing its radius to show it's relevance. Is there a component which already do so , if not what is the best way to do this.

thanks.

+1  A: 

Flare has a component which is similar to the concentric circle example in the link you have posted. See Layouts > CirclePack in the demo.

I am not yet sure what you mean by 'associating a number'. Try this: Rendering text on a path.

dirkgently
Thanks dirkgently , but mainly i want to know how to associate a number with any of the circles , be it with any of the example for which i gave a link above.
Ashish
like for example , i want to have something like this http://www.chicagocarto.com/images/quadcities.jpg ,but i would like to have number size to be in proportion with the size of the circle. Going through the link u posted , looks like i should be looking for how to embed fonts inside a circle.
Ashish
Yes, alongwith font embedding, you will need to scale them according to your needs.
dirkgently
A: 
  • Actionscript Drawing API - example here
  • Degrafa - Graphics framework which makes the Drawing API easier to use and includes a circle class
Brandon
+2  A: 

Here's a quick example on how you could do it (to be continued to achieve your particular needs)

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;
     }
    }
}
Theo.T
thanks Theo.T , it works like a charm, just what i needed , thanks again.
Ashish
Just what I needed too!
TWith2Sugars
A: 

how can I give inputs to the radius and label, it is not prompting anywhere....

please help me... i need this.