1 Reply Latest reply on Jan 29, 2010 11:12 PM by David_F57

    how to draw a hollow ring in flex

    prajnith_flex

      i gotta requirement to draw a ring in my project... currentlty am drawing a circle with border and decreased alpha value.... it pretend to be a ring but it is not...... here is my code:

       

       

                                     var spr:Sprite = event.target.parent as Sprite;
                                   
                                      s = new Sprite();
                                      s.graphics.clear();
                                      s.graphics.lineStyle(5, 0xFF0000);                               
                                      s.graphics.beginFill(0xffffff);//d9d9d9  0xfbfbfb
                                      s.alpha=0.4;
                                     
                                     
                                      s.graphics.drawCircle(spr.mouseX,spr.mouseY,10);
                                      s.graphics.endFill();
                                      img.addChild(s);
                                      addChild(img);

       

       

       

      any one hepl me out plz

        • 1. Re: how to draw a hollow ring in flex
          David_F57 Level 5

          Hi,

           

          The following code is just a basic ring you could do things like mouse events etc and they will only respond to the ring itself as the 'group' has the mouseenabledwheretransparent set to false.

           

          The width of the ring is controlled by the stroke weight

           

           

          MyRing.mxml - you can use as a component or just use copy the group into your application

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="library://ns.adobe.com/flex/spark"

          xmlns:mx="library://ns.adobe.com/flex/mx" width="300" height="300" mouseEnabledWhereTransparent="false">

          <s:Ellipse top="0" left="0" bottom="0" right="0">

          <s:stroke>

          <s:SolidColorStroke color="0x000000" weight="20"/>

          </s:stroke>

          </s:Ellipse>

          </s:Group>

           

           

          David