printjob
Its the same with anything, until you need to use the functionality of a given class or object in a project, you never delve into it unless you’re an ardent explorer type person!. I found the need to quickly explore the printing capabilities of Flash MX 2004 and was pleasantly surprised.
一切都一样,除非您需要在项目中使用给定类或对象的功能,否则除非您是一个热情的资源管理者类型的人,否则请不要研究它! 我发现有必要快速探索Flash MX 2004的打印功能,感到很惊讶。
In Flash MX 2004, the new PrintJob class is much more powerful than the print() and printAsBitmap() functions in previous versions, allowing you to print individual MovieClips, sections of MovieClips (using print area parameters) or entire levels with simplistic ease.
在Flash MX 2004中,新的PrintJob类比以前版本中的print()和printAsBitmap()函数更强大,从而使您可以轻松打印单个MovieClip,MovieClip的各个部分(使用打印区域参数)或整个级别。
In the example outlined here (source code found here), I needed to quickly print out a given number of MovieClips from the stage (example shown below).
在此处概述的示例(在此处找到源代码 )中,我需要从舞台中快速打印出给定数量的MovieClip(如下所示的示例)。
ScreenShot of Stage
舞台截图
I created the following function to pass in a simple array of MovieClips allowing me to add multiple pages to the print queue.
我创建了以下函数来传递一个简单的MovieClips数组,从而可以将多个页面添加到打印队列中。
function PrintWhat(WhatToPrint:Array) { var PrintQueue = new PrintJob(); var PrintStart:Boolean = PrintQueue.start(); if (PrintStart) { for (i=0; i<=whattoprint.length; i++) { printqueue.addpage(whattoprint); } PrintQueue.send(); } } //Prints Specific MovieClips PrintWhat([MCPrint, MCPrint002,MCPrint003]); //Prints a Level //PrintWhat([0]); =whattoprint.length;>
函数PrintWhat(WhatToPrint:Array){var PrintQueue = new PrintJob(); var PrintStart:Boolean = PrintQueue.start(); 如果(PrintStart){for(i = 0; i <= whattoprint.length; i ++){printqueue.addpage(whattoprint ); } PrintQueue.send(); }} //打印特定的MovieClips PrintWhat([MCPrint,MCPrint002,MCPrint003]); //打印一个级别// PrintWhat([0]); = whattoprint.length;>
The PrintWhat() function accepts the array of MovieClips or levels as a parameter, start a new print job using the PrintJob object, call the start() method which then triggers the print dialog. The start() method returns a Boolean true or false value based on whether the user clicks ‘OK’ or ‘Cancel’ in the print dialog box, and the inner condition when PrintStart is true is triggered or stepped over.
PrintWhat()函数接受MovieClips或关卡数组作为参数,使用PrintJob对象启动新的打印作业,调用start()方法,然后触发打印对话框。 start()方法根据用户在打印对话框中单击“确定”还是“取消”返回布尔true或false值,并触发或跳过PrintStart为true时的内部条件。
If the user chose to print and clicks ‘OK’, the incoming WhatToPrint array is parsed, and pages are added to the print queue using the addPage() method and the job is sent to the printer using the send() method.
如果用户选择打印并单击“确定”,则将解析传入的WhatToPrint数组,并使用addPage()方法将页面添加到打印队列中,并使用send()方法将作业发送到打印机。
Note: You can pass extra parameters for printing portions of MovieClips, but I
注意:您可以传递额外的参数来打印MovieClips的某些部分,但我
翻译自: https://www.sitepoint.com/messing-with-the-printjob-class/
printjob
相关资源:java PrinterJob 操作打印机