5 Replies Latest reply on Oct 27, 2009 2:40 AM by Pareek fx

    Draw String using graphics ?????

    Pareek fx Level 1

      Hi all,

       

      I need to have text displayed on a sprite.Can we draw strings as graphics in flex, the way we do it in .NET using drawString

        • 1. Re: Draw String using graphics ?????
          Daniel Freiman Level 1

          The easiest way to render text is to add a flash.text.TextField to the

          Sprite.  (The flash.text.engine package is newer, more powerful, and would

          also work but is more complicated.)  Check the livedocs for the specific

          version of flex you're using.  And remember, TextFields don't size

          themselves so you need to set the width and height explicitly.  There is no

          way to do this by going directly at the graphic object (without manually

          creating a font renderer yourself).

           

          - Daniel Freiman

          • 2. Re: Draw String using graphics ?????
            Pareek fx Level 1

            Thanks Daniel,

             

            I am using the same for now..But in this case I am avble to dispatch the

            events related to the graphics object to which th TextField sprite is added.

             

            we draw a polygon ,then add a textfield to it in the way as described by

            you.But by doing so we are not able to dispatch the roll over event

            associated with the polygn to which the Text Field is added.

            Any idea to this...

             

            Thank You

             

            2009/10/26 Daniel Freiman <forums@adobe.com>

             

            The easiest way to render text is to add a flash.text.TextField to the

            Sprite.  (The flash.text.engine package is newer, more powerful, and would

            also work but is more complicated.)  Check the livedocs for the specific

            version of flex you're using.  And remember, TextFields don't size

            themselves so you need to set the width and height explicitly.  There is no

            way to do this by going directly at the graphic object (without manually

            creating a font renderer yourself).

            >

            - Daniel Freiman

            >

            • 3. Re: Draw String using graphics ?????
              Daniel Freiman Level 1

              If the TextField is not interactive (the user can't edit or select the text)

              set the mouseEnabled=false.  I think this should make the mouse act as if

              the textfield weren't there.  The other option would be to create a sprite,

              draw the polygon on that sprite, and then place the polygon on top of the

              textfield.

               

              - Dan

              • 4. Re: Draw String using graphics ?????
                Pareek fx Level 1

                Daniel, we have tried using mouseEnabled=false,but it doesn't works.

                Using the second option suggested by you will make the TextField invisible .

                As the polygon placed over it will hide it after filling the polygon with

                some color.

                 

                Thanks a ton for replying

                 

                We'll wait for your response.

                 

                Thank you

                 

                 

                 

                 

                2009/10/27 Daniel Freiman <forums@adobe.com>

                 

                If the TextField is not interactive (the user can't edit or select the

                text)

                set the mouseEnabled=false.  I think this should make the mouse act as if

                the textfield weren't there.  The other option would be to create a sprite,

                draw the polygon on that sprite, and then place the polygon on top of the

                textfield.

                >

                - Dan

                >

                • 5. Re: Draw String using graphics ?????
                  Pareek fx Level 1

                  Hi Daniel,

                   

                  Thanks  a lot.

                  We worked a bit on the code after u r advice abt. mouseEnabled property and

                  finally we have resolved the issue.

                   

                  We assigned mouseEnabled,mouseChildren and buttonmode property as false on

                  the sprite of which text field was a child.

                  This way we achieved what was required.

                   

                  Thanks a ton

                   

                  Pareek

                   

                   

                  2009/10/27 manish pareek <manish.deepak@gmail.com>

                   

                  Daniel, we have tried using mouseEnabled=false,but it doesn't works.

                  Using the second option suggested by you will make the TextField invisible

                  .

                  As the polygon placed over it will hide it after filling the polygon with

                  some color.

                  >

                  Thanks a ton for replying

                  >

                  We'll wait for your response.

                  >

                  Thank you

                  >

                  >

                  >

                  >

                  2009/10/27 Daniel Freiman <forums@adobe.com>

                  >

                  If the TextField is not interactive (the user can't edit or select the

                  >> text)

                  >> set the mouseEnabled=false.  I think this should make the mouse act as if

                  >> the textfield weren't there.  The other option would be to create a

                  >> sprite,

                  >> draw the polygon on that sprite, and then place the polygon on top of the

                  >> textfield.

                  >>

                  >> - Dan

                  >>