2 Replies Latest reply on Oct 23, 2007 8:52 AM by MikeBurns76

    graphics.draw() issues

    MikeBurns76
      I have a custom UIComponent that always measures 50x50 pixels (in the measure() function). I use the Graphics object to draw a filled box that covers the whole area. I then draw a few circles and add text outside of the box. I do this so that when I reference the object, I know the (0,0) coordinate is at the top left of the box and I dont worry about the text or circles.

      Some problems occur when I draw circles only on the left side, or when I draw a filled circle on the right side: I get an infinitely wide filled box whose origin (0,0) is where I just drew the circle. Ill try to post an image somewhere so you can see this problem.

      Has anyone else seen this, or is there some problem inherent in drawing outside of an objects measurements?
        • 1. Re: graphics.draw() issues
          rkschulz Level 1
          Mike,

          not sure whether this is related but I tend to run into this problem at bit as well end a work around seem to be to
          throw a couple of .endFill()s in, even if you don't draw anything with a fill pattern.

          I haven't quite worked out what's going on but managed to fix most of the problems I have with phantom boxes
          and stuff appearing by doing this. See how you go.

          R.

          • 2. Re: graphics.draw() issues
            MikeBurns76 Level 1
            I think I have found my probelm:

            graphics.beginFill()
            graphics.drawRect(...)
            graphics.endFill()

            This code is in the UpdateDisplayList() function of my custom component. I commented out the drawRect function, and saw that the phantom box still appeared in the same distinct color defined for the code in quiestion(different than all other fills used, so I know it is THIS fill that is the problem). And the box's coordinates directly correlate to a line that I draw earlier. This leads me to believe that the UpdateDisplayList function gets called again before the end fill.

            Ill try throwing in endFills, or try placing this fill code earlier in the updateDisplayList method.