2 Replies Latest reply on Jan 30, 2008 4:16 PM by jtn23

    Crop components that extend beyonds bounds of canvas

    jtn23
      Hi,

      i've got the following sample code that draws a larger square with another smaller square rendered halfway inside the larger square and halfway out:

      public function drawSquare():void {
      var largeSquare:UIComponent = new UIComponent();
      largeSquare.graphics.beginFill(0x0000FF, 0.5);
      largeSquare.graphics.drawRect(800, 0, 400, 400);
      largeSquare.graphics.endFill();
      addChild(largeSquare);

      var smallSquare:UIComponent = new UIComponent();
      smallSquare.graphics.beginFill(0xFF0000, 0.5);
      smallSquare.graphics.drawRect(1100, 100, 200, 200);
      smallSquare.graphics.endFill();
      largeSquare.addChild(smallSquare);
      }


      What I'd like to do is restrict the rendering of the smaller square to be within the bounds of the larger square, in other words, I want to crop the part of the smaller square that's hanging off the larger square. Any help is much appreciated. thanks.