Printing class: extract > modify > repack swc file

Hi,

I am currently tying to migrate a Flash app to Adobe Air. The purpose of this app is to print and the new printing options in Air 2.0 would be ideal for my app. The new printing options in Air 2.0 are listed here:
http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/printing/PrintJob.html

I’ve been prgramming and it works like a charm for A4. But I would also like to print to A3 and a custom paper size. The available papersizes are listed here:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/printing/PaperSize.html

So now I would like to add A3 and my custom size. This however seems to be a bit complicated, but I like complicated :slight_smile:

NOTE 1
I’m just beginning to scratch the surface of this subject so I’m not an expert in writing/using custom classes and packing them into swc’s and such.
NOTE 2
I’m not 100% sure if the method suggested below is legal/approved by adobe or the rules on this forum. If not please remove what is suggested below.

Oh and please correct me if I’m wrong in my assumption/suggestions below.

Ok so here’s the plan. When Flash compiles to Air it probably uses airglobal.swc which is located in:
Program Files\Adobe\Adobe Flash CS5\Common\Configuration\ActionScript 3.0\AIR2.0

This .swc can be extracted with 7zip. After extraction there are two files:
catalog.xml and library.swf
when I decompile library.swf I have a collection of 485 .as files which must be the classes used when Flash generates the Air file. There are three folders and a set of .as files in the directory after decompiling. The folder names are “AS3” “adobe” and “flash”
There are only two .as files that contain papersize settings:
PaperSize.as and PrintJob.as (located in the folder flash\printing)

The code in PaperSizes.as :


package flash.printing
{
    final public class PaperSize extends Object
    {
        public static const LETTER:String = "letter";
        ...........(other papersizes here).......
        public static const ENV_PERSONAL:String = "env_personal";

        public function PaperSize()
        {
            return;
        }// end function
    }
}

View the full code here: http://tinycoke.com/7ggZv

The function that cecks papersizes in PrintJob.as


public function selectPaperSize(paperSize:String) : void
        {
            if (paperSize != PaperSize.LETTER)
            {
            }
            ...........(other papersizes here).......

            if (paperSize != PaperSize.ENV_PERSONAL)
            {
                Error.throwError(ArgumentError, 2008, "PaperSize");
            }
            this.invoke(kSelectPaperSize, paperSize);
            return;
        }// end function

View full code here: http://tinycoke.com/CRVtf

Ok, now would this work ?

  • adding these lines in PaperSizes.as:
    public static const A3:String = “a3”;
    public static const CUSTOM:String = “custom”;

  • adding this in PrintJob.as:
    if (paperSize != PaperSize.A3)
    {
    }
    if (paperSize != PaperSize.CUSTOM)
    {
    }

(“CUSTOM” is going to be replaced by… the name of our papersize in windows I guess ?)

And let’s say this does the trick, who should I re-pack all these .as files into an swf and xml. And after that how should i pack those two files into the new modified airglobal.swc ?
If someone knows how to do this, would it be ok to attach a zip containing all the .as files ?

Thank you verry much for reading all this :slight_smile:
And thanks in advance for you reply.