GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ASPack/MEPrint.as at master · SaffronCode/ASPack Expand file tree/ Copy pathMEPrint.asMore file actions 226 lines (187 loc) · 5.71 KB / Copy pathMEPrint.asFile metadata and controls226 lines (187 loc) · 5.71 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 // ************************* // * COPYRIGHT // * DEVELOPER: MTEAM ( [email protected] ) // * ALL RIGHTS RESERVED FOR MTEAM // * YOU CAN'T USE THIS CODE IN ANY OTHER SOFTWARE FOR ANY PURPOSE // * YOU CAN'T SHARE THIS CODE // ************************* package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.MovieClip; import flash.display.Sprite; import flash.display.Stage; import flash.geom.Matrix; import flash.geom.Rectangle; import flash.media.CameraRoll; import flash.printing.PrintJob; public class MEPrint { private static var resolution:uint = 2 ; /**you can name objects or just objects names that you need to remove befor print procces started<br> * leave the list of objects or target that you need to be visible on printed page<br> * set print mode from class MEPrintMode<br> * <br> * returns boolean that shows if the capture or print was sucssefull or not*/ public static function start(myStage:Stage,mePrintMode:uint=1,removeTheseObjects:Array=null,removeTheseNames:Array=null ,showTheseObjects:Array=null,showTheseNames:Array=null):Boolean { var printStarted:Boolean ; var captured:Boolean = false; var listOfObjects:Array = new Array(); var listOfObjectsVisibelity:Array = new Array(); var listOfWaterMarks:Array = new Array(); var listOfWaterMarksVisibelity:Array = new Array(); var i:int; //to hide list try{ for(i =0 ; i < removeTheseNames.length ; i++) { listOfObjects = listOfObjects.concat(find(removeTheseNames[i],myStage)); } }catch(e){}; try{ listOfObjects = listOfObjects.concat(removeTheseObjects); trace('removed objects added'+removeTheseObjects.length); }catch(e){}; trace('DisplayObject : '+listOfObjects.length); //to hide list ended //to show list try{ for(i=0 ; i < removeTheseNames.length ; i++) { listOfWaterMarks = listOfWaterMarks.concat(find(showTheseNames[i],myStage)); } }catch(e){}; try{ listOfWaterMarks = listOfWaterMarks.concat(showTheseObjects); }catch(e){}; //to show list ended //invisible all useless objects for(i=0 ; i<listOfObjects.length ; i++) { listOfObjectsVisibelity[i] = DisplayObject(listOfObjects[i]).visible ; DisplayObject(listOfObjects[i]).visible = false ; } //visible all useless objects for(i=0 ; i<listOfWaterMarks.length ; i++) { listOfWaterMarksVisibelity[i] = DisplayObject(listOfWaterMarks[i]).visible ; DisplayObject(listOfWaterMarks[i]).visible = true ; } //print all page with 1024 * 768 size var bd:BitmapData = new BitmapData(myStage.stageWidth*resolution,myStage.stageHeight*resolution,false,0xffffff); bd.draw(myStage,new Matrix(resolution,0,0,resolution)); var bm:Bitmap = new Bitmap(bd,"auto",true); var page:Sprite = new Sprite(); page.addChild(bm); //myStage.addChild(page); var printJ:PrintJob = new PrintJob(); printJ.jobName = "SJEC"; if(mePrintMode!=MEPrintMode.capture) { try{ printStarted = printJ.start(); } catch(e) { printStarted = false; } } else { printStarted = false; } if(printStarted) { page.graphics.lineStyle(1,0); page.graphics.beginFill(0xffffff); page.graphics.lineTo(printJ.paperWidth,0); page.graphics.lineTo(printJ.paperWidth,printJ.paperHeight); page.graphics.lineTo(0,printJ.paperHeight); if(printJ.orientation == "portrait") { bm.rotation = 90 ; bm.width = printJ.paperWidth ; bm.height = printJ.paperHeight ; bm.scaleX = bm.scaleY = Math.min(bm.scaleX,bm.scaleY); //if bitmap rotate , the real with and height will be switch bm.x = (printJ.paperWidth-bm.width)/2+bm.width ; bm.y = (printJ.paperHeight-bm.height)/2 ; //trace('♣ printJ.paperHeight:'+printJ.paperHeight+' , '+printJ.paperWidth+' - '+bm.width+","+bm.height); try{ printJ.addPage( page ); } catch(e) { printStarted= false; } } else //if(printJ.orientation == "landscape") { bm.width = printJ.paperWidth ; bm.height = printJ.paperHeight ; bm.scaleX = bm.scaleY = Math.min(bm.scaleX,bm.scaleY); bm.x = (printJ.paperWidth-bm.width)/2; bm.y = (printJ.paperHeight-bm.height)/2; try{ printJ.addPage( page ); } catch(e) { printStarted= false; } } printJ.send(); } if(!printStarted && mePrintMode!=MEPrintMode.print) { trace('print not started'); //save bitmap data on gallery if(CameraRoll.supportsAddBitmapData) { var cameraRoll:CameraRoll = new CameraRoll(); cameraRoll.addBitmapData(bd); captured = true ; } } //return every thing to preveuse situation for(i=0 ; i<listOfObjects.length ; i++) { DisplayObject(listOfObjects[i]).visible = listOfObjectsVisibelity[i] ; } for(i=0 ; i<listOfWaterMarks.length ; i++) { DisplayObject(listOfWaterMarks[i]).visible = listOfWaterMarksVisibelity[i] ; } if(printStarted || captured) { return true ; } else { return false; } } private static function find(targetName:String,searchIn:DisplayObjectContainer):Array { var myList:Array = new Array(); for(var i=0 ; i<searchIn.numChildren ; i++) { var targ:* = searchIn.getChildAt(i); if(targ.name == targetName) { myList.push(targ); } if(targ is DisplayObjectContainer) { myList = myList.concat(find(targetName,targ)); } } return myList ; } } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |