Programmatically print SWF
I was looking for a way to programmatically print a SWF file. The stand-alone Flash player has an option to print a SWF, however there is no shell action registered for it.
After looking around a bit, I found that probably the easiest way is to use the ActionScript PrintJob API:
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.printing.PrintJob;
public class Printer extends Sprite
{
private var loader:Loader;
public function Printer()
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.load(new URLRequest("content.swf"));
}
public function onLoaded(e:Event):void
{
var pj:PrintJob = new PrintJob();
if(pj.start()) {
var sprite:Sprite = new Sprite();
sprite.addChild(loader);
pj.addPage(sprite);
pj.send();
}
}
}
}