6 Replies Latest reply on Oct 15, 2008 7:52 AM by slmille4

    Clipping dynamic Canvas content?

    slmille4
      I have a canvas in which I'm loading some Sprites, and I need to clip the edges of the canvas, but even though I have clipContent="true", the Sprites still spill over the edge of the canvas. If I add a large Image component via Flex Builder, then on runtime the clipping gets triggered, and strangely, any Sprites that are added start getting clipped correctly, suggesting that something got triggered to make it work correctly. Is there anything I can do to get the Canvas to start clipping dynamically loaded content?

      Stephen M.
        • 1. Re: Clipping dynamic Canvas content?
          Level 7

          "rtsshuy5uy" <webforumsuser@macromedia.com> wrote in message
          news:gd30og$mlb$1@forums.macromedia.com...
          >I have a canvas in which I'm loading some Sprites, and I need to clip the
          >edges
          > of the canvas, but even though I have clipContent="true", the Sprites
          > still
          > spill over the edge of the canvas. If I add a large Image component via
          > Flex
          > Builder, then on runtime the clipping gets triggered, and strangely, any
          > Sprites that are added start getting clipped correctly, suggesting that
          > something got triggered to make it work correctly. Is there anything I
          > can do
          > to get the Canvas to start clipping dynamically loaded content?

          I think you need to have something in the negative part of the canvas (put a
          dummy object at -1, 0)


          • 2. Re: Clipping dynamic Canvas content?
            slmille4 Level 1
            Ack, didn't work. These Sprites area draggable, so I dragged one of them into the far top left corner, and it stayed on top of the canvas. I know that the Sprite is actually a child of the canvas and clipContent from looking at the debugger so I'm not sure what is going wrong :-\
            • 3. Re: Clipping dynamic Canvas content?
              Level 7

              "rtsshuy5uy" <webforumsuser@macromedia.com> wrote in message
              news:gd3cmq$6rq$1@forums.macromedia.com...
              > Ack, didn't work. These Sprites area draggable, so I dragged one of them
              > into
              > the far top left corner, and it stayed on top of the canvas. I know that
              > the
              > Sprite is actually a child of the canvas and clipContent from looking at
              > the
              > debugger so I'm not sure what is going wrong :-\

              No, you need to actually put it there either programmatically or in MXML


              • 4. Re: Clipping dynamic Canvas content?
                slmille4 Level 1
                Alright, I've gotten that to work for x,y,xScale, and yScale, but I need to be able to implement skew and rotate as well, which seems a little more difficult. I don't know if there is a Flex-specific way to do this, but the way that I know how to do it in Flash, with transform.matrix, causes the problem I've described. I've attached some code demonstrating the problem. Changing the x and y parameters make the image clip correctly, using the more flexible transform.matrix results in the image not getting clipped.

                Stephen M.
                • 5. Re: Clipping dynamic Canvas content?
                  Level 7

                  "rtsshuy5uy" <webforumsuser@macromedia.com> wrote in message
                  news:gd3nll$irg$1@forums.macromedia.com...
                  > Alright, I've gotten that to work for x,y,xScale, and yScale, but I need
                  > to be
                  > able to implement skew and rotate as well, which seems a little more
                  > difficult.
                  > I don't know if there is a Flex-specific way to do this, but the way that
                  > I
                  > know how to do it in Flash, with transform.matrix, causes the problem I've
                  > described. I've attached some code demonstrating the problem. Changing
                  > the x
                  > and y parameters make the image clip correctly, using the more flexible
                  > transform.matrix results in the image not getting clipped.

                  Instead of giving your actual image that you're working with the negative
                  coordinates, try adding a dummy component that is used solely to cause
                  clipping.


                  • 6. Re: Clipping dynamic Canvas content?
                    slmille4 Level 1
                    Ok I think I finally got it. I decided to try a mask, figuring that that would be the most reliable method, and it seemed to do what I wanted. Thanks for the tips, I was pretty stuck on this one.