1 Reply Latest reply on Feb 8, 2014 9:36 AM by Piaf1986

    ImageSnapshot and Popup Windows


      Hi, I have an application that has several windows that were created using the PopUpManager. I would like the user to be able to take a screenshot of the the app so I am using the ImageSnapshot class.


      The application is being captured but none of the pop up windows are showing up. Is there any way I can achieve this?


      I have attached an example of the problem. You will need to ensure that the project is set to require Flash Player Version 10.0 in the flex compiler options.


      To see the problem click on 'Pop up box' then click on 'Capture Image'


      Thanks in advance


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
                  import mx.graphics.codec.PNGEncoder;
                  import mx.graphics.ImageSnapshot;
                  import mx.managers.PopUpManager;
                  import mx.containers.TitleWindow;
                  import flash.net.FileReference;
                  private var titleWindow : TitleWindow;
                  private function captureImage() : void{
                     var sn : ImageSnapshot;
                     sn = ImageSnapshot.captureImage(form,100,new PNGEncoder());
                      var file:FileReference = new FileReference();
                     file.save(sn.data, "captured.png");
                  private function showPopUp() : void {
                      if (titleWindow == null)
                          titleWindow = TitleWindow(PopUpManager.createPopUp(this.form,TitleWindow,false));
                          titleWindow.height = 115;
                          titleWindow.width = this.form.width / 2;
                          titleWindow.title = "My title window " + new Date();
                          titleWindow = null;
          <mx:VBox id="form">
              <mx:Button label="Capture Image" click="captureImage();" />
              <mx:TextArea id="txtBox" width="800" height="600"    />
              <mx:Button label="Pop up box" click="showPopUp();" />

        • 1. Re: ImageSnapshot and Popup Windows

          late response but...

          The problem is that PopupManager "creates new top-level windows and places or removes those windows from the layer on top of all other visible windows", which means Popup is not a child of Application.

          The SystemManager "parents all displayable things within the application like the main mx.core.Application instance and all popups, tooltips, cursors, and so on", so to capture BitmapData you need to reference object which contains popup and Application instance.


          Im not sure if this is preferable way to do it, but to get snapshot of everything visible ond screen you can use SystemManagers "getSWFRoot" method as in ImageSnapshot.captureBitmapData(SystemManager.getSWFRoot(this));