0 Replies Latest reply on Sep 13, 2010 8:56 AM by tenshisage

    Printing a graphic with a gradient mask in Flex 3—problem

    tenshisage

      Hello, I am fairly new to flex development. I am puting together a little program that allows the user to upload a picture add a vignette mask in order to achieve a soft edge,  and have a problem I cannot  find an answer anywhere, maybe someone could help me please.
      I want  to print a the user photo with a gradient mask or vignette from flex. I managed  to show the image correctly on screeen with the gradient mask using  this class but the output to paper is a rectangle without the soft mask.

       

      //package to add the mask for display

       

      package com.dm.graphics
      {
         import flash.display.Graphics;
         import mx.containers.Canvas;
         import flash.display.GradientType;
        
         public class FrameBorderSoft extends Canvas
         {
            override protected function updateDisplayList(w:Number, h:Number):void
            {
               super.updateDisplayList(w,h);
              
               var g:Graphics = this.graphics;
               g.clear();

       

              
               g.beginGradientFill(GradientType.RADIAL, [0x000000, 0x000000, 0x000000, 0x000000],
               [1,1,0.8,0],
               [1,128,195,255],
               horizontalGradientMatrix(0,0,w,h) );
               g.drawRect(0,0,w,h);
               g.endFill();
            }

       

         }
      }

       

      It  works beautifully until I try to print the graphic. The image prints  but without the gradient edges (soft) instead it is just a sharp edge  rectangle.
      Does anyone know how to do this?
      Here is my print function:

       

      private function doPrint():void {
                    
                      // Create an instance of the FlexPrintJob class.
                     
                      var myPrintJob:FlexPrintJob = new FlexPrintJob();
                     
                      // Start the print job.
                      if (myPrintJob.start() != true) return;
                 
                      // Add the object to print. Do not scale it.
                      if (tabnavigator1.selectedChild == img1) {
                 //switchcolor is a variable to detect if the user changed the background to white or clear.       
                               switchcolor = 100;
                            //printCF is the card front container with the photo masked
                         myPrintJob.addObject(printCF, FlexPrintJobScaleType.NONE);
                         myPrintJob.printAsBitmap = false;        
                  
                      } else if (tabnavigator1.selectedChild == img1b) {
                         switchcolor = 100;
                         myPrintJob.addObject(printCB, FlexPrintJobScaleType.NONE);
                      }
      I hope this helps to visualize,
      I would greatly appreciate any assistance or advise.