1 Reply Latest reply on Nov 18, 2009 8:20 AM by scottchu.tw

    Clipping graphics

    tnirenstein Level 1
      I am using the Graphics object of a canvas to draw using the available instructions (beginFill, drawCircle, etc). I want the image i am drawing to be clipped by the canvas if it is too big. The ClipContent property of the canvas doesn't clip images drawn in the Graphics object.

      Any quick ideas how to accomplish this?

      Thanks in advance,

      Todd
        • 1. Re: Clipping graphics
          scottchu.tw

          clipContent action will only activate when one or many of its already-displayed children are not inside its viewable rectangle thoroughly.

          At this time, if scroll policies are not off, you'll see the scrollbars appeared.

           

          So if you do graphic drawing after it already displayed, it won't do on-fly clipping unless you override the underlying updateDisplayList() or measure() methods, which is way too complex.

           

          A less complex & feasible way, although may memory & time-comsuming if view rectangle is very large, is using mask.

           

          Create a mask displayobject with fully filled contents & set it as mask of the drawing displayobject, you can carry out the clipping effect.

           

          Furthermore, you can provide different mask to carry out fancy clipping effect.

           

          Scott Chu @ Taiwan.