3 Replies Latest reply on Aug 11, 2010 11:24 PM by fleRavix

    Image not appearing

    UbuntuPenguin Level 4

      Hello Everyone ,

        The application I am working on uses printing.  To print something that hasn't been rendered yet , I do the whole "make invisible , add/remove from the topApplication" dance.  I decided to add an image to one of my printing components , and this is where problems arose.

       

           When I embed the image source , the image prints accordingly.  However , when I set the image source dynamically , the image refuses to print.  Is there a way I can force the image to draw itself.  I have tried validateNow , and validateDisplayList as well as setting the creationPolicy="all" , but to no avail.

       

      Sincerely ,

        Ubu

        • 1. Re: Image not appearing
          ShardulSingh Level 3

          Hi,

          I dont't think that without rendering image you can print it.Please try this hope this will fullfill your requirement.

          Let me know it helps or not you.

           

          MainApplication.mxml

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  layout="vertical">
                  <mx:Script>
                      <![CDATA[
                          import mx.managers.CursorManager;
                          import mx.controls.Alert;
                          import mx.logging.targets.TraceTarget;
                          import mx.rpc.soap.LoadEvent;
                         
                          private var isLoaded : Boolean;
                          private function loadImageInInvisibleBackground():void
                          {
                               img.load("assets/imageToPrint.jpg");
                          }
                         
                          private function yourPrintFunction():void
                          {
                              loadImageInInvisibleBackground();
                              CursorManager.setBusyCursor();

                          }
                         
                          private function loadComplete(event : Event) : void
                          {
                              CursorManager.removeBusyCursor();
                              Alert.show("Your Image is loaded, now comment this alert and call your print method here.");
                              //Write code to Print the 'yourPrintalbleScreen' or its image here.
                          }
                         
                      ]]>
                  </mx:Script>
            
          <mx:ViewStack width="500" height="400" creationPolicy="all">
                 <mx:Canvas id="yourVisibleFrontScreen" width="100%" height="100%">
                    <mx:VBox horizontalAlign="center" verticalAlign="middle">
                        <mx:Label text="This is your visible screen"/>
                        <mx:Button label="Print" click="yourPrintFunction()"/>
                    </mx:VBox>
                </mx:Canvas>
                <mx:Canvas id="yourPrintalbleScreen" width="100%" height="100%">
                    <mx:Image id="img" width="100%" height="100%" scaleContent="true" complete="loadComplete(event)" />
                </mx:Canvas>
            </mx:ViewStack>
           
          </mx:Application>

           

           

           

           

           

           

           

           

           

           

           

           

          with Regards,

           

          Shardul Singh Bartwal

          • 2. Re: Image not appearing
            BhaskerChari Level 4

            Hi UbuntuPenguin,

             

            Can you post the sample source code...reproducing your problem..???

             

             

            Thanks,

            Bhasker

            • 3. Re: Image not appearing
              fleRavix Level 2

              Hi,

              Before priniting, create an Image SnapShot of the image, then add the snapshot to the print. You Need not print the image dynamically.

               

              Steps:

               

              1. ImageSnapshot.

              2. Add the snapshot to print

              3. print.

               

              You will definately acheive success.

               

              Mark this if helpful