10 Replies Latest reply on Oct 29, 2009 10:35 PM by Flex harUI

    drawing overlapping circles using flex and actionscript

    AsiriSilva

      im trying to add some dynamic circles to a panel at runtime

      this is my code

       

       

      drawing functions in actionscript file

      -----------------------------------

      public class Circle extends UIComponent{
         
          private var upColor:uint   = 0xFFCC00;
          private var overColor:uint = 0xCCFF00;
          private var downColor:uint = 0x00CCFF;
          private var xCord:uint;
          private var yCord:uint;
          private var size:uint;

       

      public function Circle(x:uint,y:uint,size_:uint){
         
          this.xCord=x;
          this.yCord=y;
          this.size=size_;
          var a:SimpleButton=new SimpleButton();
          a.downState      = Draw(x,y,size_,downColor);
          a.overState      = Draw(x,y,size_,overColor);
          a.upState        = Draw(x,y,size_,upColor);
          a.hitTestState   = Draw(x,y,size_,upColor);
          a.useHandCursor  = true;
          addChild(a);
         a.addEventListener(MouseEvent.CLICK,click);
         
          }

       

          private function Draw(x:uint,y:uint,size:uint,bgColor:uint):Shape
          {
              var temp:Shape=new Shape();
              temp.graphics.beginFill(0x000000);
              temp.graphics.drawCircle(x,y,size+2);
              temp.graphics.endFill();
              temp.graphics.beginFill(bgColor);
              temp.graphics.drawCircle(x,y,size)
              temp.graphics.endFill();
              return temp;
          }

      ..........................................

       

       

      flex code..

      -------------------------------------

      public function addCircle():void {
                     
                      for(var i:int=0; i<10; i++)
                      {
                          var cr:Circle=new Circle(500,200,20);
                          c_array.Add(cr);
                          mypanel.addChild(cr);
                      }     
                     
                  }

       

      although i try to overlap all the circles.. what i get is different from what i expect.

      image of the output is included..

       

      what i need is.. when i gv the same cordinate.. all the circles should be overlapped and should be displayed as ONE circle

       

      any suggestions ?

       

      thanks.