適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隱藏篩選
flash.printing 

PrintJob  - AS3

套件x

最上層
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

語言元素

全域常數
全域函數
運算子
陳述式、關鍵字和指令
特殊類型

附錄

新增內容
編譯器錯誤
編譯器警告
執行階段錯誤
移轉至 ActionScript 3
支援的字元集
僅限 MXML 標籤
移動 XML 元素
Timed Text 標籤
不建議元素清單
AccessibilityImplementation 常數
如何使用 ActionScript 範例
法律聲明
套件flash.printing
類別public class PrintJob
繼承PrintJob Inheritance EventDispatcher Inheritance Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9

您可以使用 PrintJob 類別來建立內容,並且將這項內容列印至一或多個頁面。 這個類別可讓您顯示使用者可看見、動態或螢幕外的內容,並以單一的「列印」對話方塊提示使用者,以及依照對應此內容的相同比例列印未經縮放的文件。這個功能對於顯示及列印動態內容 (如資料庫內容和動態文字) 特別有用。

行動裝置瀏覽器支援:行動裝置瀏覽器不支援此類別。

AIR 描述檔支援:所有桌上型電腦作業系統都支援此項功能,但行動裝置或 AIR for TV 裝置不支援。您可以使用 PrintJob.isSupported 屬性測試執行階段的支援狀況。如需有關跨多個描述檔之 API 支援的詳細資訊,請參閱 AIR 描述檔支援

請使用 PrintJob() 建構函式建立列印工作。

此外,藉由 PrintJob 類別的屬性,您的文件能夠讀取使用者的印表機設定,如頁高、頁寬和影像旋轉,並可設定文件,使其能夠以動態方式將 Flash 內容格式化,以符合印表機的設定。

注意: ActionScript 3.0 沒有將 PrintJob 物件限制在單一影格 (如先前版本的 ActionScript 作法)。 不過,由於作業系統會在使用者按一下「列印」對話方塊中的「確定」按鈕之後,對使用者顯示列印狀態資訊,所以您應該儘快呼叫 PrintJob.addPage()PrintJob.send(),以便將頁面傳送到多功緩衝處理區域。 延遲抵達含有 PrintJob.send() 呼叫的影格,也會延遲列印程序。

此外,還會將 15 秒鐘的程式碼逾時限制套用至下列間隔:

  • PrintJob.start() 和第一個 PrintJob.addPage()
  • PrintJob.addPage() 和下一個 PrintJob.addPage()
  • 最後一個 PrintJob.addPage()PrintJob.send()

如果以上任何這些間隔超過 15 秒鐘,下一次針對 PrintJob 實體之 PrintJob.start() 的呼叫便會傳回 false,而且 PrintJob 實體的下一個 PrintJob.addPage() 會使 Flash Player 或 Adobe AIR 擲出執行階段例外。

檢視範例



公用屬性
 屬性定義自
      active : Boolean
[靜態] [唯讀] 指出列印工作目前是否正在作用中。
PrintJob
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
      copies : int
對於後續新增至列印工作中的所有頁面,列印系統要列印的份數。
PrintJob
      firstPage : int
[唯讀] 使用者在作業系統的「列印」對話方塊中,輸入範圍的第一頁頁碼。
PrintJob
      isColor : Boolean
[唯讀] 指出目前列印設定所選取的印表機,使用彩色 (true) 或灰階 (false) 列印。
PrintJob
  isSupported : Boolean
[靜態] [唯讀] 指出目前的平台支援 (true) 或不支援 (false) PrintJob 類別。
PrintJob
      jobName : String
列印工作的名稱或標題。
PrintJob
      lastPage : int
[唯讀] 使用者在作業系統的「列印」對話方塊中,輸入範圍的最後一頁頁碼。
PrintJob
      maxPixelsPerInch : Number
[唯讀] 所選印表機的實體解析度,以每英吋像素為單位。
PrintJob
  orientation : String
要列印的影像方向。
PrintJob
  pageHeight : int
[唯讀] 頁面實際可列印區域中可以置中的最大區域高度,以點為單位。
PrintJob
  pageWidth : int
[唯讀] 頁面實際可列印區域中可以置中的最大區域寬度,以點為單位。
PrintJob
      paperArea : Rectangle
[唯讀] 印表機媒體的邊界,以點數為單位。
PrintJob
  paperHeight : int
[唯讀] 整體紙張高度,以點為單位。
PrintJob
  paperWidth : int
[唯讀] 整體紙張寬度,以點為單位。
PrintJob
      printableArea : Rectangle
[唯讀] 印表機媒體可列印區域的邊界,以點數為單位。
PrintJob
      printer : String
取得或設定要用於目前列印工作的印表機。
PrintJob
      printers : Vector.<String>
[靜態] [唯讀] 以 String 名稱值提供可用印表機的清單。
PrintJob
      supportsPageSetupDialog : Boolean
[靜態] [唯讀] 指出 Flash 執行階段環境是否支援個別的「頁面設定」對話方塊。
PrintJob
公用方法
 方法定義自
  
建立一個 PrintJob 物件,可讓您用來列印一頁或多頁。
PrintJob
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。
EventDispatcher
  
addPage(sprite:Sprite, printArea:Rectangle = null, options:PrintJobOptions = null, frameNum:int = 0):void
會將指定的 Sprite 物件當作單一頁面,傳送至列印多工緩衝處理區域。
PrintJob
 Inherited
會將事件傳送到事件流程。
EventDispatcher
 Inherited
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。
EventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
會從 EventDispatcher 物件移除偵聽程式。
EventDispatcher
  
    selectPaperSize(paperSize:String):void
設定紙張大小。
PrintJob
  
在成功呼叫 start() 或 start2() 及 addPage() 方法後,傳送多工緩衝處理頁面到印表機。
PrintJob
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
  
如果目前的環境可支援,顯示作業系統的「頁面設定」對話方塊。
PrintJob
  
顯示作業系統的「列印」對話方塊,並開始進行多工緩衝處理。
PrintJob
  
    start2(uiOptions:PrintUIOptions = null, showPrintDialog:Boolean = true):Boolean
或者,會顯示作業系統的「列印」對話方塊、開始進行多工緩衝處理,並可能修改 PrintJob 唯讀屬性值。
PrintJob
  
    terminate():void
通知印列工作應該終止不應傳送。
PrintJob
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。
EventDispatcher
事件
 事件 摘要 定義自
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。EventDispatcher
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。EventDispatcher
屬性詳細資訊
    

active

屬性
active:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

指出列印工作目前是否正在作用中。在下列兩種情況下,列印工作為作用中 (屬性值為 true):

  • 正顯示「頁面設定」或「列印」對話方塊。
  • 已經呼叫 start()start2() 方法,並得到 true 傳回值,且並未呼叫 send()terminate() 方法。

如果這個屬性為 true,且呼叫 showPageSetupDialog()start()start2() 方法,執行階段會擲出例外。



實作
    public static function get active():Boolean

相關 API 元素

    

copies

屬性 
copies:int

語言版本: ActionScript 3.0
執行階段版本: AIR 2

對於後續新增至列印工作中的所有頁面,列印系統要列印的份數。這個值是使用者在作業系統「列印」對話方塊中輸入的副本數量。如果「列印」對話方塊中未顯示副本數量,或「列印」對話方塊未向使用者顯示,則值為 1 (除非它曾經由應用程式程式碼所改變)。



實作
    public function get copies():int
    public function set copies(value:int):void
    

firstPage

屬性 
firstPage:int  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

使用者在作業系統的「列印」對話方塊中,輸入範圍的第一頁頁碼。如果使用者要求列印所有頁面,或是「列印」對話方塊中未顯示頁數範圍,或是「列印」對話方塊未向使用者顯示,則這個屬性為零。



實作
    public function get firstPage():int
    

isColor

屬性 
isColor:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

指出目前列印設定所選取的印表機,使用彩色 (true) 或灰階 (false) 列印。

如果無法判定彩色或灰階值,則值為 true



實作
    public function get isColor():Boolean

isSupported

屬性 
isSupported:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: Flash Player 10.1, AIR 2

指出目前的平台支援 (true) 或不支援 (false) PrintJob 類別。



實作
    public static function get isSupported():Boolean
    

jobName

屬性 
jobName:String

語言版本: ActionScript 3.0
執行階段版本: AIR 2

列印工作的名稱或標題。作業系統通常使用工作名稱做為列印佇列中的工作標題,或做為列印到檔案的工作預設名稱。

如果您尚未呼叫 start()start2(),且您尚未設定屬性值,這個屬性值為 null

對於您在 PrintJob 實體執行的每個列印工作,在呼叫 start()start2() 方法之前,先設定這個屬性。

預設值為 null



實作
    public function get jobName():String
    public function set jobName(value:String):void

擲回值
IllegalOperationError — 當 active 屬性為 true,而程式碼嘗試設定屬性時。
    

lastPage

屬性 
lastPage:int  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

使用者在作業系統的「列印」對話方塊中,輸入範圍的最後一頁頁碼。如果使用者要求列印所有頁面,或是「列印」對話方塊中未顯示頁數範圍,或是「列印」對話方塊未向使用者顯示,則這個屬性為零。



實作
    public function get lastPage():int
    

maxPixelsPerInch

屬性 
maxPixelsPerInch:Number  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

所選印表機的實體解析度,以每英吋像素為單位。會根據作業系統報告的目前列印設定計算值。

如果無法判定解析度,值為標準預設值。在 Linux 上的預設值是 600 ppi,在 Mac 作業系統上是 360 ppi。在 Windows 上,任何印表機解析度都可使用,所以不需要預設值。



實作
    public function get maxPixelsPerInch():Number

orientation

屬性 
orientation:String

語言版本: ActionScript 3.0
執行階段版本: Flash Player 9 - read only, AIR 1.0 - read only, AIR 2 - read-write

要列印的影像方向。 可接受的值定義為 PrintJobOrientation 類別的常數。

注意:在 AIR 2 或更新版本,先設定這個屬性,再啟動列印工作,可在「頁面設定」及「列印」對話方塊中設定預設紙張方向。在列印工作過程中設定屬性 (在 呼叫 start()start2() 之後,可在工作內之設定頁面範圍的紙張方向。



實作
    public function get orientation():String
    public function set orientation(value:String):void

相關 API 元素

pageHeight

屬性 
pageHeight:int  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

頁面實際可列印區域中可以置中的最大區域高度,以點為單位。會忽略所有使用者設定的邊界。 只有在呼叫 PrintJob.start() 方法之後,才能使用這個屬性。

注意:對於 AIR 2 或更新版本,不建議使用這個屬性。請改使用 printableArea,這會以小數為單位,測量可列印區域並準確地描述非中心 (Off-center) 的可列印區域。



實作
    public function get pageHeight():int

相關 API 元素

pageWidth

屬性 
pageWidth:int  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: Flash Player 9, AIR 1.0

頁面實際可列印區域中可以置中的最大區域寬度,以點為單位。會忽略所有使用者設定的邊界。 只有在呼叫 PrintJob.start() 方法之後,才能使用這個屬性。

注意:對於 AIR 2 或更新版本,不建議使用這個屬性。請改使用 printableArea,這會以小數為單位,測量可列印區域並準確地描述非中心 (Off-center) 的可列印區域。



實作
    public function get pageWidth():int

相關 API 元素

    

paperArea

屬性 
paperArea:Rectangle  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

印表機媒體的邊界,以點數為單位。這個值使用的座標系統,與後續addPage() 呼叫使用的座標系統相同。



實作
    public function get paperArea():Rectangle

paperHeight

屬性 
paperHeight:int  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

整體紙張高度,以點為單位。 只有在呼叫 PrintJob.start() 方法之後,才能使用這個屬性。

注意:對於 AIR 2 或更新版本,不建議使用這個屬性。請改使用 paperArea,它會以小數為單位測量紙張大小。



實作
    public function get paperHeight():int

相關 API 元素

paperWidth

屬性 
paperWidth:int  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

整體紙張寬度,以點為單位。 只有在呼叫 PrintJob.start() 方法之後,才能使用這個屬性。

注意:對於 AIR 2 或更新版本,不建議使用這個屬性。請改使用 paperArea,它會以小數為單位測量紙張大小。



實作
    public function get paperWidth():int

相關 API 元素

    

printableArea

屬性 
printableArea:Rectangle  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

印表機媒體可列印區域的邊界,以點數為單位。這個值使用的座標系統,與後續addPage() 呼叫使用的座標系統相同。



實作
    public function get printableArea():Rectangle
    

printer

屬性 
printer:String

語言版本: ActionScript 3.0
執行階段版本: AIR 2

取得或設定要用於目前列印工作的印表機。傳遞至 setter 及由 getter 傳回的字串,應該和在 Array 中由 printers() 方法傳回的其中一個字串相符。若要指出應使用預設印表機,請將值設定為 null。在不能判斷預設印表機的作業系統上,這個屬性值為 null

     import flash.printing.PrintJob;
     
     var myPrintJob:PrintJob = new PrintJob();
     myPrintJob.printer = "HP_LaserJet_1";
     myPrintJob.start();
     

設定這個屬性的值,會立刻嘗試選取印表機。如果印表機選取失敗,這個屬性值會重設為之前的值。在嘗試設定印表機值後讀取該值,可以判定印表機值是否設定成功,並確認它符合設定的值。

作用中列印工作的 printer 屬性無法變更。請在呼叫 start()start2() 方法成功之後,及呼叫 send()terminate() 失敗之前變更它。



實作
    public function get printer():String
    public function set printer(value:String):void
    

printers

屬性 
printers:Vector.<String>  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

以 String 名稱值提供可用印表機的清單。這不是預先計算的清單,而是在呼叫函數時產生的。如果沒有任何印表機可以使用,或系統不支援列印,則值為 null。如果系統支援列印,但無法傳回印表機清單,則值為具有單一元素的向量 (它的 length 屬性為 1)。在這樣的情況下,如果無法判斷目前的印表機名稱,則該單一元素會是實際印表機名稱或預設名稱。



實作
    public static function get printers():Vector.<String>
    

supportsPageSetupDialog

屬性 
supportsPageSetupDialog:Boolean  [唯讀]

語言版本: ActionScript 3.0
執行階段版本: AIR 2

指出 Flash 執行階段環境是否支援個別的「頁面設定」對話方塊。如果這個屬性為 true,您可以呼叫 showPageSetupDialog() 方法,顯示作業系統的頁面設定對話方塊。



實作
    public static function get supportsPageSetupDialog():Boolean

相關 API 元素

建構函式詳細資料

PrintJob

()建構函式
public function PrintJob()

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9

建立一個 PrintJob 物件,可讓您用來列印一頁或多頁。 建立 PrintJob 物件之後,您需要依照下列序列使用 PrintJob.start()PrintJob.addPage()PrintJob.send() 方法,將列印工作傳送至印表機。

例如,您可以用下列程式碼中顯示的自訂參數,取代 myPrintJob.addPage() 方法呼叫的 [params] 預留位置文字:

 // create PrintJob object
 var myPrintJob:PrintJob = new PrintJob();
  
 // display Print dialog box, but only initiate the print job
 // if start returns successfully.
 if (myPrintJob.start()) {
  
    // add specified page to print job
    // repeat once for each page to be printed
    try {
      myPrintJob.addPage([params]);
    }
    catch(e:Error) {
      // handle error 
    }
    try {
      myPrintJob.addPage([params]);
    }
    catch(e:Error) {
      // handle error 
    }
 
    // send pages from the spooler to the printer, but only if one or more
    // calls to addPage() was successful. You should always check for successful 
    // calls to start() and addPage() before calling send().
    myPrintJob.send();
 }
 

AIR 2 或更新版本,您可以建立並使用多個 PrintJob 實體。在 PrintJob 實體中設定的屬性,在列印完成後仍繼續保留。這可以讓您重複使用 PrintJob 實體,並維持使用者選取的列印偏好設定,而不會對您應用程式中的其他內容提供不同的列印偏好設定。對於在 Flash Player 及 AIR 2 之前版本的內容,當第一個 PrintJob 物件仍在作用中時,不能建立第二個 PrintJob 物件。如果您在第一個 PrintJob 物件仍在作用中時,藉由呼叫 new PrintJob() 建立第二個 PrintJob 物件,則無法建立第二個 PrintJob 物件。 所以在建立第二個 PrintJob 前,您應該檢查 myPrintJob 值。


擲回值
IllegalOperationError — Flash Player 及 AIR 2 之前的 AIR 版本,如果有另一個 PrintJob 物件正在作用中,則會擲出例外。

相關 API 元素

方法詳細資訊

addPage

()方法
public function addPage(sprite:Sprite, printArea:Rectangle = null, options:PrintJobOptions = null, frameNum:int = 0):void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

會將指定的 Sprite 物件當作單一頁面,傳送至列印多工緩衝處理區域。 在使用此方法之前,您必須先建立 PrintJob 物件,然後使用 start()start2()。接著,在呼叫 addPage() 一次或更多次以進行列印工作之後,使用 send() 將多工緩衝處理區域中的頁面傳送到印表機。換句話說,建立 PrintJob 物件之後,應依序使用 start()start2()addPage()send(),將列印工作傳送至印表機。在對 start() 進行單次呼叫後,您可以多次呼叫 addPage(),在列印工作中列印多個頁面。

如果 addPage() 造成 Flash Player 擲出例外 (例如,如果您沒有呼叫 start(),或使用者取消列印工作),對於 addPage() 的任何後續呼叫也都會失敗。然而,如果先前以 addPage() 為目標的呼叫已經成功,則最後的 send() 命令便會將已成功排入多工緩衝處理區域的頁面傳送到印表機。

如果列印工作需要 15 秒鐘以上才能完成 addPage() 作業,Flash Player 便會在下次進行 addPage() 呼叫時擲出例外。

如果您傳遞 printArea 參數的值,printArea 矩形的 xy 座標便會對應到頁面中可列印區域的左上角 (0, 0 座標)。唯讀屬性 pageHeightpageWidth 會描述 start() 設定的可列印區域。由於列印結果會對齊頁面中可列印區域的左上角,所以當 printArea 中定義的區域大於頁面上的可列印區域時,列印結果便會裁切 printArea 所定義之區域的右側或底部 (或在兩處同時裁切)。 在 Flash Professional,如果您沒有傳遞 printArea 的值,而且「舞台」大於可列印區域,則會發生相同類型的裁切結果。在 Flex 或 Flash Builder,如果您沒有傳遞 printArea 的值,且螢幕大於可列印區域,則會發生相同類型的裁切結果。

如果您想要在列印之前縮放 Sprite 物件,請在呼叫這個方法之前設定縮放屬性 (請參閱 flash.display.DisplayObject.scaleXflash.display.DisplayObject.scaleY),然後在列印後將它們設回原來的值。 Sprite 物件的縮放與 printArea 無關。 也就是說,如果您指定的列印區域為 50 x 50 像素,便會列印 2500 像素。 如果縮放 Sprite 物件,依然會列印相同的 2500 像素,不過會是以縮放的大小列印 Sprite 物件。

Flash Player 列印功能支援 PostScript 以及非 PostScript 印表機。 非 PostScript 印表機會將向量轉換成點陣圖。

參數

sprite:Sprite — 包含要列印內容的 Sprite。
 
printArea:Rectangle (default = null) — 指定要列印之區域的 Rectangle 物件。

矩形的寬度與高度都是像素值。 印表機會使用點做為列印度量單位。 點是固定的實體大小 (1/72 英吋),不過像素在螢幕上的大小則取決於特定螢幕的解析度。 因此,像素與點之間的轉換率,必須根據印表機設定及是否已縮放 sprite 來決定。 未縮放並具有 72 像素寬的 Sprite,會列印為一英吋的寬度,無論螢幕解析度為何,每一點都會等於一個像素。

您可以使用下列等式,將英吋或公分轉換成崔普 (twip) 或點 (1 崔普相當於 1/20 的點):

  • 1 點 = 1/72 英呎 = 20 崔普
  • 1 英呎 = 72 點 = 1440 崔普
  • 1 公分 = 567 崔普

如果省略 printArea 參數,或是它並未正確傳遞,則會列印 sprite 參數的整個區域。

如果您不想指定 printArea 的值,卻想指定 optionsframeNum 的值,請傳遞 null 做為 printArea 的值。

 
options:PrintJobOptions (default = null) — 選擇性參數,會指定列印為向量或點陣圖。 預設值為 null,代表要求進行向量列印。 若要將 sprite 列印為點陣圖,請將 PrintJobOptions 物件的 printAsBitmap 屬性設定為 true。 請在決定是否要將 printAsBitmap 設定為 true 時,記住下列建議:
  • 如果您要列印的內容含有點陣圖影像,請將 printAsBitmap 設定為 true,以包含所有 Alpha 透明度及顏色效果。
  • 如果您要列印的內容不包含點陣圖影像,省略此參數即可以高品質向量格式列印內容。

如果省略 options 或傳遞錯誤,就會以向量格式進行列印。 如果您不想指定 options 的值,卻想指定 frameNumber 的值,請傳遞 null 做為 options 的值。

 
frameNum:int (default = 0) — 可讓您指定 MovieClip 物件中要列印之影格的選擇性數字。傳遞 frameNum 並不會在影格叫用 ActionScript。如果您省略這個參數,而 sprite 參數為 MovieClip 物件,則會列印 sprite 目前的影格。


擲回值
Error — 如果您沒有呼叫 start(),或使用者取消列印工作,則會擲出例外。

相關 API 元素

    selectPaperSize

()方法 
public function selectPaperSize(paperSize:String):void

語言版本: ActionScript 3.0
執行階段版本: AIR 2

設定紙張大小。paperSize 參數可接受的值,必須是 PaperSize 類別中的常數。呼叫這個方法對於列印設定的影響,就跟使用者在「頁面設定」或「列印」對話方塊中選擇頁面大小一樣。

您可以隨時呼叫這個方法。可以在列印工作開始之前呼叫這個方法,以便在「頁面設定」和「列印」對話方塊中設定預設紙張大小。在列印工作過程中呼叫這個函數,可在工作內之頁面範圍設定紙張大小。

     import flash.printing.PrintJob;
     import flash.printing.PaperSize;
     
     var myPrintJob:PrintJob = new PrintJob();
     myPrintJob.selectPaperSize(PaperSize.ENV_10);
     

參數

paperSize:String — 列印工作後續頁面使用的紙張大小。


擲回值
ArgumentError — 如果 paperSize 參數不是 PaperSize 類別已定義的可接受值之一。

相關 API 元素

send

()方法 
public function send():void

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

在成功呼叫 start()start2()addPage() 方法後,傳送多工緩衝處理頁面到印表機。

如果呼叫 start()start2() 方法失敗,或呼叫 addPage() 方法擲回例外,這個方法就不會成功。若要避免錯誤,請在呼叫這個方法之前,先檢查 start()start2() 方法傳回 true,並捕捉任何 addPage() 例外。下列範例示範在呼叫這個方法之前,如何適當地檢查錯誤:

     var myPrintJob:PrintJob = new PrintJob();
     if (myPrintJob.start()) {
       try {
         myPrintJob.addPage([params]);
       }
       catch(e:Error) {
          // handle error 
       }
     
       myPrintJob.send();
     }
     

相關 API 元素

    showPageSetupDialog

()方法 
public function showPageSetupDialog():Boolean

語言版本: ActionScript 3.0
執行階段版本: AIR 2

如果目前的環境可支援,顯示作業系統的「頁面設定」對話方塊。請使用 supportsPageSetupDialog 屬性判斷是否支援「頁面設定」。

     import flash.printing.PrintJob;
     
     var myPrintJob:PrintJob = new PrintJob();
     if (myPrintJob.supportsPageSetupDialog)
     {
         myPrintJob.showPageSetupDialog();
     }
     

傳回值
Boolean — 如果使用者在「頁面設定」對話方塊中選擇「確定」,則為 true。這表示某些 PrintJob 屬性可能已經改變。如果使用者在「頁面設定」對話方塊中選擇「取消」,則傳回 false

擲回值
IllegalOperationError — 如果系統不支援「頁面設定」。請使用 supportsPageSetupDialog 屬性判斷是否支援「頁面設定」。
 
IllegalOperationError — 如果有任何列印工作 (包括目前這個列印工作) 正在作用中。

相關 API 元素

start

()方法 
public function start():Boolean

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Player 9.

顯示作業系統的「列印」對話方塊,並開始進行多工緩衝處理。「列印」對話方塊讓使用者能變更列印設定。 當 PrintJob.start() 方法成功傳回時 (亦即使用者按一下「列印」對話方塊中的「確定」),便會填入下列屬性,代表使用者選擇的列印設定:

屬性類型單位備註
PrintJob.paperHeightNumberPoints整頁高度。
PrintJob.paperWidthNumberPoints整頁寬度。
PrintJob.pageHeightNumberPoints頁面上實際可列印區域的高度;會忽略所有使用者設定的邊界。
PrintJob.pageWidthNumberPoints頁面上實際可列印區域的寬度;會忽略所有使用者設定的邊界。
PrintJob.orientation字串"portrait" (flash.printing.PrintJobOrientation.PORTRAIT) 或 "landscape" (flash.printing.PrintJobOrientation.LANDSCAPE)。

注意:如果使用者取消「列印」對話方塊,就不會填入這些屬性。

使用者在「列印」對話方塊中按一下「確定」以後,播放程式就會開始將多工緩衝處理的列印工作送到作業系統。 由於作業系統接著會對使用者顯示關於列印進度的資訊,所以您應該盡快呼叫 PrintJob.addPage()PrintJob.send(),將這些頁面傳送至多工緩衝處理區域。 您可以使用此方法所填入的唯讀高度、寬度與方向屬性,來設定列印輸出之格式。

PrintJob.addPage()PrintJob.send() 進行任何後續呼叫之前,請先測試並查看此方法是否傳回 true (當使用者在作業系統的「列印」對話方塊中按一下「確定」時):

     var myPrintJob:PrintJob = new PrintJob();
        if(myPrintJob.start()) {
          // addPage() and send() statements here
        }
     

對於指定的列印工作實體,如果下列任何間隔超過 15 秒鐘,下一次呼叫 PrintJob.start() 便會傳回 false

  • PrintJob.start() 和第一個 PrintJob.addPage()
  • 一個 PrintJob.addPage() 及下一個 PrintJob.addPage()
  • 最後一個 PrintJob.addPage()PrintJob.send()

傳回值
Boolean — 如果使用者在「列印」對話方塊出現時按一下「確定」,值會是 true;如果使用者按一下「取消」或發生錯誤,則會是 false

擲回值
IllegalOperationError — 在 AIR 2 或更新版本,如果另一個 PrintJob 目前正在作用中

相關 API 元素

    start2

()方法 
public function start2(uiOptions:PrintUIOptions = null, showPrintDialog:Boolean = true):Boolean

語言版本: ActionScript 3.0
執行階段版本: AIR 2

或者,會顯示作業系統的「列印」對話方塊、開始進行多工緩衝處理,並可能修改 PrintJob 唯讀屬性值。

uiOptions 參數允許呼叫者控制要在「列印」對話方塊顯示哪些選項。請參閱 PrintUIOptions 類別。如果 showPrintDialog 為 false,就會忽略這個參數。

即使 showPrintDialogtrue,這個方法的行為會與 start() 方法不同。在一些作業系統上,start() 會顯示「頁面設定」對話方塊,然後顯示「列印」對話方塊。相反地,start2() 從不顯示「頁面設定」對話方塊。

在下列範例中,「列印」對話方塊的最小及最大頁面設定,是在對話方塊向使用者顯示之前就設定好:

     import flash.printing.PrintJob;
     import flash.printing.PrintUIOptions;
     
     var myPrintJob:PrintJob = new PrintJob();
     var uiOpt:PrintUIOptions = new PrintUIOptions();
     uiOpt.minPage = 1;
     uiOpt.maxPage = 3;
     var accepted:Boolean = myPrintJob.start2(uiOpt);
     

參數

uiOptions:PrintUIOptions (default = null) — 指定「列印」對話方塊會向使用者顯示哪些選項的物件。如果 showPrintDialog 參數為 false,將會忽略這個值。
 
showPrintDialog:Boolean (default = true) — 在啟動列印工作之前,是否向使用者顯示「列印」對話方塊。

傳回值
Boolean — 如果使用者在「列印」對話方塊出現時按一下「確定」,或如果「列印」對話方塊沒有顯示也沒有錯誤,值會是 true;如果使用者按一下「取消」或發生錯誤,則會是 false

擲回值
IllegalOperationError — 如果正在顯示「頁面設定」對話方塊,或其他列印工作目前正在作用中。

相關 API 元素

    terminate

()方法 
public function terminate():void

語言版本: ActionScript 3.0
執行階段版本: AIR 2

通知印列工作應該終止不應傳送。當列印工作已經由呼叫 start()start2() 起始,但是不適合傳送任何頁面到印表機時,請使用這個方法。 一般而言,terminate() 只用於從錯誤中復原。

在呼叫這個方法之後,即可重複使用 PrintJob 實體。在可能的情況下,工作的設定都會保留供後續使用。

PrintJobExample_Simple.as

下列的範例顯示列印的基礎:建立新的 PrintJob,而且如果成功地開始,addPage() 方法會新增 Sprite 為單一頁面。send() 方法將頁面排入印表機。
package 
{ 
    import flash.printing.PrintJob; 
    import flash.display.Sprite; 
 
    public class BasicPrintExample extends Sprite 
    { 
        var myPrintJob:PrintJob = new PrintJob(); 
        var mySprite:Sprite = new Sprite();
        mySprite.graphics.beginFill(0x336699);
    mySprite.graphics.drawCircle(100, 100, 50);
 
        public function BasicPrintExample() 
        { 
            if (myPrintJob.start()) {
            try {
                myPrintJob.addPage(mySprite);
            }
            catch(e:Error) {
                // handle error 
            }
            myPrintJob.send();
        } 
    } 
}
PrintJobExample.as

下列範例將使用類別 PrintJobExample 建立一份小文件,然後將文件傳送至印表機。 這是透過下列步驟完成:
  1. 宣告兩個名為 sheet1sheet2 的 Sprite 類型變數。
  2. 呼叫 init(),為 sheet1sheet2 各指定新的 Sprite 實體,然後使用不同的引數呼叫 createSheet()
  3. createSheet()會進行下列工作:
    1. 使用傳入的 Sprite 物件,在 x = 0, y = 0 的位置繪製 100 (寬) x 200 (高) 像素的矩形,其背景為淺灰色,並具有寬度為一個像素的黑色邊框。
    2. 使用和 Sprite 相同的尺寸、將 wordWrap 屬性設定為 true 並將要做為引數傳遞給 createSheet() 的文字屬性設定為 String,以建立新的 TextField 物件 txt
    3. 如果傳入的 Object 引數不是 null,則建立新的 Sprite 實體 img,使用傳入 Object 的座標和尺寸屬性繪製一個白色矩形。 然後再將此白色矩形加入 Sprite 物件的顯示清單中 (藉由使用 addChild())。
    4. txt將 TextField 加入 Sprite 物件的顯示清單中 (藉由使用 addChild())。
  4. 回到建構函式中,呼叫已啟用 (未標示註解) 的列印方法。 由於方法都非常相似,因此以下只說明 printOnePerPage()
  5. printOnePerPage()會進行下列工作:
    1. 宣告名為 pj 的新 PrintJob 物件,並將 pagesToPrint 宣告為 uint。
    2. 開啟作業系統原本的列印對話方塊,並等待使用者按一下 OK
    3. 檢查方向,如果選取的是「橫向」,便會擲回錯誤並結束。
    4. 設定 sheet1sheet2 的頁面高度及寬度。
    5. 使用 addPage()sheet1sheet2 傳送到列印多工緩衝處理區域。
    6. 如果要列印的頁數大於 0,便會列印多工緩衝處理區域中的所有頁面。
  6. 呼叫 draw() 方法,依據舞台大小調整這兩個 Sprite 屬性,並重新定位 sheet2 使它對齊 sheet1 的右端。

注意: 根據偏好設定,會將建構函式設定為三種列印方法 (一張紙列印一頁、一張紙列印二頁或列印在紙張的上半部) 中的一種。 除非使用程式碼註解確實停用其中兩種列印方法,否則這個範例將不會正確運作。 這個範例的設定會呼叫 printOnePerPage()

package {
    import flash.printing.PrintJob;
    import flash.printing.PrintJobOrientation;
    import flash.display.Stage;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.geom.Rectangle;
       
    public class PrintJobExample extends Sprite {
        private var sheet1:Sprite;
        private var sheet2:Sprite;
           
        public function PrintJobExample() {
            init();
            printOnePerPage();
//            printTwoPerPage();
//            printTopHalf();
            draw();
        }
        
        private function init():void {
            sheet1 = new Sprite();
            createSheet(sheet1, "Once upon a time...", {x:10, y:50, width:80, height:130});

            sheet2 = new Sprite();
            createSheet(sheet2, "There was a great story to tell, and it ended quickly.\n\nThe end.", null);
        }
        
        private function createSheet(sheet:Sprite, str:String, imgValue:Object):void {
            sheet.graphics.beginFill(0xEEEEEE);
            sheet.graphics.lineStyle(1, 0x000000);
            sheet.graphics.drawRect(0, 0, 100, 200);
            sheet.graphics.endFill();
            
            var txt:TextField = new TextField();
            txt.height = 200;
            txt.width = 100;
            txt.wordWrap = true;
            txt.text = str;
            
            if(imgValue != null) {
                var img:Sprite = new Sprite();
                img.graphics.beginFill(0xFFFFFF);
                img.graphics.drawRect(imgValue.x, imgValue.y, imgValue.width, imgValue.height);
                img.graphics.endFill();
                sheet.addChild(img);
            }
            sheet.addChild(txt);
        }
        
        private function printOnePerPage():void {
            var pj:PrintJob = new PrintJob();
            var pagesToPrint:uint = 0;
            if(pj.start()) {                
                if(pj.orientation == PrintJobOrientation.LANDSCAPE) {    
                    throw new Error("Without embedding fonts you must print one sheet per page with an orientation of portrait.");
                }
                
                sheet1.height = pj.pageHeight;
                sheet1.width = pj.pageWidth;
                sheet2.height = pj.pageHeight;
                sheet2.width = pj.pageWidth;

                try {
                    pj.addPage(sheet1);
                    pagesToPrint++;
                }
                catch(e:Error) {
                    // do nothing
                }

                try {
                    pj.addPage(sheet2);
                    pagesToPrint++;
                }
                catch(e:Error) {
                    // do nothing
                }

                if(pagesToPrint > 0) {
                    pj.send();
                }
            }
        }
        
        private function printTwoPerPage():void {
            var pj:PrintJob = new PrintJob();
            var pagesToPrint:uint = 0;
            if(pj.start()) {                
                if(pj.orientation == PrintJobOrientation.PORTRAIT) {
                    throw new Error("Without embedding fonts you must print two sheets per page with an orientation of landscape.");
                }
                
                sheet1.height = pj.pageHeight;
                sheet1.width = pj.pageWidth/2;
                sheet2.height = pj.pageHeight;
                sheet2.width = pj.pageWidth/2;

                var sheets:Sprite = new Sprite();
                sheets.addChild(sheet1);
                sheets.addChild(sheet2);
                sheets.getChildAt(1).x = sheets.getChildAt(0).width;
                try {
                    pj.addPage(sheets);
                    pagesToPrint++;
                }
                catch(e:Error) {
                    // do nothing
                }

                if(pagesToPrint > 0) {
                    pj.send();
                }
            }
        }

        private function printTopHalf():void {
            var pj:PrintJob = new PrintJob();
            var pagesToPrint:uint = 0;
            if(pj.start()) {                
                if(pj.orientation == PrintJobOrientation.PORTRAIT) {
                    throw new Error("Without embedding fonts you must print the top half with an orientation of landscape.");
                }
                
                sheet1.height = pj.pageHeight;
                sheet1.width = pj.pageWidth/2;
                sheet2.height = pj.pageHeight;
                sheet2.width = pj.pageWidth/2;

                var sheets:Sprite = new Sprite();
                sheets.addChild(sheet1);
                sheets.addChild(sheet2);
                sheets.getChildAt(1).x = sheets.getChildAt(0).width;
                try {
                    pj.addPage(sheets, new Rectangle(0, 0, sheets.width, sheets.height/2));
                    pagesToPrint++;
                }
                catch(e:Error) {
                    // do nothing
                }

                if(pagesToPrint > 0) {
                    pj.send();
                }
            }
        }


        private function draw():void {
            var sheetWidth:Number = this.stage.stageWidth/2;
            var sheetHeight:Number = this.stage.stageHeight;
            
            addChild(sheet1);
            sheet1.width = sheetWidth;
            sheet1.height = sheetHeight;
            
            addChild(sheet2);
            sheet2.width = sheetWidth;
            sheet2.height = sheetHeight;
            sheet2.x = sheet1.width;
        }        
    }
}
PrintJobExample.2.as

下列範例將示範其他列印功能。範例初始化 PrintJob 設定,包括列印份數、頁面大小 (legal) 及列印方向 (橫向)。它首先會強制顯示「頁面設定」對話方塊,接著顯示「列印」對話方塊來啟動列印工作。
 
package 
 { 
     import flash.display.Sprite; 
     import flash.display.Stage; 
     import flash.geom.Rectangle; 
     import flash.printing.PaperSize; 
     import flash.printing.PrintJob; 
    import flash.printing.PrintJobOrientation; 
    import flash.printing.PrintUIOptions; 
    import flash.text.TextField; 
      
     public class PrintJobExample extends Sprite 
     { 
         private var bg:Sprite; 
         private var txt:TextField; 
        private var pj:PrintJob; 
        private var uiOpt:PrintUIOptions; 
  
         public function PrintJobExample():void 
         { 
            var pj = new PrintJob(); 
            uiOpt = new PrintUIOptions(); 
            initPrintJob(); 
             initContent(); 
             draw(); 
             printPage(); 
         } 
          
         private function printPage():void 
         { 
            if (pj.supportsPageSetupDialog) 
            { 
                pj.showPageSetupDialog(); 
            }
            
             if (pj.start2(uiOpt, true)) 
             { 
                   try 
                 { 
                     pj.addPage(this, new Rectangle(0, 0, 100, 100)); 
                 } 
                 catch (error:Error) 
                 { 
                     // Do nothing. 
                 } 
                 pj.send(); 
             } 
             else 
             { 
                 txt.text = "Print job terminated"; 
                pj.terminate(); 
             } 
         } 
         
         private function initContent():void 
         { 
             bg = new Sprite(); 
             bg.graphics.beginFill(0x00FF00); 
             bg.graphics.drawRect(0, 0, 100, 200); 
             bg.graphics.endFill(); 
              
             txt = new TextField(); 
             txt.border = true; 
             txt.text = "Hello World"; 
         } 
          
        private function initPrintJob():void 
        { 
            pj.setPaperSize(PaperSize.LEGAL); 
            pj.orientation = PrintJobOrientation.LANDSCAPE; 
            pj.copies = 2; 
            pj.jobName = "Flash test print";
        } 
         
         private function draw():void 
         { 
             addChild(bg); 
             addChild(txt); 
             txt.x = 50; 
             txt.y = 50; 
         } 
     } 
}




[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。