2 Replies Latest reply on Mar 12, 2008 12:48 PM by Solerous

    UIComponent image capture

    David Havrda
      Does anyone know how I can do a runtime image capture of a UIComponent? Specifically what I would like to do is have a canvas which has several controls on it. I would like to get an image capture of this canvas with all of its controls. Any ideas?
        • 1. Re: UIComponent image capture
          atta707 Level 2
          ImageSnapshot is the name of the class you're looking for and captureImage(IBitmapDrawable) is the method. All of your Flex components are IBitmapDrawable.

          ATTA
          • 2. UIComponent image capture
            Solerous Level 1
            I'm having the same problem. I can use ImageSnapshot works when I statically generate my data, but somehow it only draws the elements added during the creation of the component and if I later add data from messaging or with actionscript (addChild), it only draws the original elements and not the new data. Here is my method:

            private function captureImg(comp:UIComponent):void {
            var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(comp);
            var imageByteArray:ByteArray = imageSnap.data as ByteArray;
            imgSave.saveImage(imageByteArray);
            }

            I also have this line in my init() method: ImageSnapshot.defaultEncoder = PNGEncoder;

            But I don't even know if I need that for sure.


            I then send it to a java servlet to write it to a file. As I said, it works but only writes the visual components added during initialization of the application.