6 Replies Latest reply on Nov 21, 2007 10:14 AM by chucktangy

    Parent not clipping children in certain cases


      I've run into 2 different cases where clipping doesn't work. One I can produce a test case that reproduces the problem where another I have a program that is demostrating the problem, but I don't know why. I've found a hack that causes clipping to get turned back on, but I wanted to know if anyone else has encountered these problems. I'm surprised because clipping is such a basic neccessity, and easy to implement I'm confused as to why Flex is so buggy. Here is one way of reproducing my first clipping problem. Create two canvases one as a child of the other, and set a bottom constraint on the child.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Canvas backgroundColor="black" x="10" y="10" width="313" height="218" horizontalScrollPolicy="off" verticalScrollPolicy="off">
      <mx:Canvas id="c1" backgroundColor="blue" right="0" height="166" left="0" y="149"/>

      <mx:Canvas backgroundColor="black" x="367" y="10" width="313" height="218" horizontalScrollPolicy="off" verticalScrollPolicy="off">
      <mx:Canvas id="c2" backgroundColor="red" height="166" bottom="-97" width="313" x="0"/>

      The above mxml will show clipping work (in blue), and clipping failing (in red). Turn off the use of bottom constraints and it will start working. I've filled a bug on the above code. I'd like to file another bug on the second one I've found, but I can't seem to boil it to down to a simple test cases.

      The next one I'm not sure why it's not clipping. I have a series of images being displayed on a Canvas in CD Coverflow in iTunes/iPhone like UI. The images will spill outside the container when they get larger than the parent. However, if I put another child whose bounds also spill outside the parent, and set visible="false" then clipping will start working and all children will be clipped properly.

      Any ideas why clipping is so flaky? Are there cases where this is by design?

        • 1. Re: Parent not clipping children in certain cases
          peterent Level 2
          I'm not sure of the first problem off the top of my head, but for number 2 I can help. Place the CoverArt into a container (eg, Canvas), create a shape (or UIComponent) that's a child of the same container and fills it (draw a solid rectangle into this shape or component) and set it as the container's mask.
          • 2. Re: Parent not clipping children in certain cases
            chucktangy Level 1

            Thanks for the reply, but doesn't flex already clip children of parents without setting having to set a mask? See my example Mxml included in this post. Is what you're suggesting a simple work around to the clipping problem? Or is this the way Flex is designed when it comes to clipping? Shouldn't a parent's bounds form the visible bounds for all of its children?

            • 3. Re: Parent not clipping children in certain cases
              peterent Level 2
              The CoverArt isn't a normal case. Yes, containers should clip their children, but it is possible to ignore that which is what CoverArt appears to do. I was working on an example and decided to use a similar component with the same problem. I needed to do a quick work-around and just assigned a mask. I haven't dived into the source to figure out a cleaner way.

              So this is atypical.
              • 4. Re: Parent not clipping children in certain cases
                I'm seeing the same thing. In my case I run a loop to create a set of N canvases. I add images or video to each one that extend beyond the boundaries of the canvas slightly. Some of them are properly clipped by the containing canvas, others are not. This is odd since each of the canvases are created in exactly the same way, using exactly the same code. It appears as though this is a bug in the Flex framework code.
                • 5. Re: Parent not clipping children in certain cases
                  peterent Level 2
                  If you feel this is a bug, please file a report at http://bugs.adobe.com/jira and supply your test case. It is important to us to locate and resolve bugs and your help in doing so is appreciated.
                  • 6. Re: Parent not clipping children in certain cases
                    chucktangy Level 1

                    It's definitely a bug. We need simplified test case that exhibits the bug so we can submit it to JIRA. There are several works arounds that you can do to get it to work. Including the one Peter provided in the form. You can see others here:


                    I don't think this problem is related to this bug though as I'm not using bottom or right constraints in doing my layout. What you describe sounds very similar to what I was doing as well. If you post your some of your code it might help in working out a test case that we can provide to JIRA so the Flex engineers can fix it. My program is not that trivial so I wasn't going to post it, but if you have one that's simpler then I'd be up for helping you work out a test case.