3 Replies Latest reply on May 13, 2009 5:44 AM by Barna Biro

    Geometry classes

    ckisthebest Level 1

      Hi I want to draw various geometrical shapes like triangle, rectanlge and polygon in my flex application.


      Which class should i use ? I know that its possible using sprite. but is it possible using UIcomponent?


      If yes which one should i use and why?




        • 1. Re: Geometry classes
          _Natasha_ Level 4


          you can use flash.display.Graphics to draw any shapes you want. All draw operations you should do there.


          From any UIComponent you can get graphics and draw something. See docs for more info.

          1 person found this helpful
          • 2. Re: Geometry classes
            Gregory Lafrance Level 6

            Usually it is best to wrap Sprites in a UIComponent as in the following code, to get the UIComponent functionality, and to be able to add Sprites directly to the display list:


            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  import mx.core.UIComponent;
                  private function init():void{
                    var mySprite:Sprite = new Sprite();
                    mySprite.graphics.drawCircle(30, 30, 30);
                    var label:TextField = new TextField();
                    label.width = 200;
                    label.text = "They call me mellow yellow...";
                    label.x = -30;
                    label.y = 80;
                    var uic:UIComponent = new UIComponent();


            If this post answers your question or helps, please mark it as such.

            • 3. Re: Geometry classes
              Barna Biro Level 3

              Hi there,


              I think that you should definitely check out this: http://www.degrafa.org/ Degrafa is a declarative graphics framework, and it's simply awesome. You can even extend their components and build your own. Check it out.


              With best regards,

              Barna Biro

              Blog: http://blog.wisebisoft.com