Mega Code Archive

 
Categories / Flex / Development
 

Using ActionScript to create a temporary container to print

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"     layout="vertical" backgroundColor="white">     <mx:Script>                  import mx.containers.VBox;         import mx.printing.*;         public function printStuff():void         {             var printJob:FlexPrintJob = new FlexPrintJob();             var tmpVBox:VBox = new VBox();             printJob.start();             addChild(tmpVBox);             tmpVBox.addChild(text1);             tmpVBox.addChild(text2);             tmpVBox.addChild(text3);             tmpVBox.addChild(text4);             printJob.addObject(tmpVBox,FlexPrintJobScaleType.NONE);             printJob.send();             removeChild(tmpVBox);         }            </mx:Script>     <mx:HBox id="myHBox1" width="100%">         <mx:Text id="text1" text="this is a test" />         <mx:Text id="text2" text="this is another test" />     </mx:HBox>     <mx:HBox id="myHBox2" width="100%">         <mx:Text id="text3" text="this is the third test." />         <mx:Text id="text4" text="this is the fourth test." />     </mx:HBox>     <mx:Button click="printStuff()" label="Print Stuff" /> </mx:Application>