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

Clipboard  - 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.desktop
類別public class Clipboard
繼承Clipboard Inheritance Object

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

Clipboard 類別會提供透過剪貼簿來傳輸資料與物件所需的容器。作業系統的剪貼簿可以透過靜態 generalClipboard 屬性存取。

Clipboard 物件可能會以一種以上的格式包含相同的資訊。以多種格式提供資訊,讓您給予其他應用程式更多機會來使用該資訊。請使用 setData()setDataHandler() 方法,將資料加入 Clipboard 物件。

標準格式如下:

  • BITMAP_FORMAT:一種 BitmapData 物件 (僅限 AIR)
  • FILE_LIST_FORMAT:File 物件的陣列 (僅限 AIR)
  • HTML_FORMAT:格式為 HTML 的字串資料
  • TEXT_FORMAT:字串資料
  • RICH_TEXT_FORMAT:內含 RTF 格式資料的 ByteArray
  • URL_FORMAT:URL 字串 (僅限 AIR)

這些具有標準格式名稱的常數是在 ClipboardFormats 類別中定義。

傳送至作業系統或者從作業系統傳送時,會在 ActionScript 資料類型和原生作業系統剪貼簿類型之間自動轉譯標準格式。

您可以使用應用程式所定義的格式,將 ActionScript 物件加入 Clipboard 物件。若某個物件可以序列化,便可以製作此物件的參考和副本。物件參考只有在原始應用程式內才有效。

如果將資訊轉換成以特定格式傳輸的運算成本很昂貴,您可以提供執行轉換的函數名稱。只有當該格式由接收的組件或應用程式所讀取時,才會呼叫此函數。請使用 setDataHandler() 方法,將延遲的顯示函數加入 Clipboard 物件。注意:在某些情況下,作業系統會在放置之前,先呼叫此函數。例如,當您使用 handler 函數,為從 AIR 應用程式拖曳至檔案系統的檔案提供資料,作業系統會在拖曳手勢離開 AIR 應用程式時,立即呼叫資料處理常式 — 通常會在資料下載和建立時,造成意外的暫停。

AIR 應用程式注意事項:傳送給 HTML 拖放和複製及貼上事件的事件物件所參考的剪貼簿物件與 AIR Clipboard 物件的類型不同。AIR 開發人員手冊中有描述 JavaScript 剪貼簿物件。

Flash Player 應用程式中注意事項:在 Flash Player 10 中,必須先有使用者事件 (例如「貼上」命令的鍵盤快速鍵,或在快顯選單的「貼上」命令上按下滑鼠),才能進行從剪貼簿貼上的作業。只有當 InteractiveObject 已經收到並開始處理貼上事件時,Clipboard.getData() 才會傳回剪貼簿內容。在任何其他情況下呼叫 Clipboard.getData() 都不會成功。在 AIR 中,相同的限制也適用於應用程式安全執行程序之外的內容。

在 Linux 上,當 AIR 應用程式關閉時,剪貼簿資料不會持續存在。

檢視範例

相關 API 元素



公用屬性
 屬性定義自
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
  formats : Array
[唯讀] 字串陣列,內含此 Clipboard 物件中可用的資料格式名稱。
Clipboard
  generalClipboard : Clipboard
[靜態] [唯讀] 作業系統剪貼簿。
Clipboard
      supportsFilePromise : Boolean
[唯讀] 指出用戶端系統是否支援檔案承諾剪貼簿格式。
Clipboard
公用方法
 方法定義自
  
建立空的 Clipboard 物件。
Clipboard
  
刪除此 Clipboard 物件中的所有資料形式。
Clipboard
  
刪除指定格式的資料形式。
Clipboard
  
getData(format:String, transferMode:String = "originalPreferred"):Object
如果存在指定格式的資料,則取回剪貼簿資料。
Clipboard
  
檢查此 Clipboard 物件中是否存在指定之格式的資料。
Clipboard
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
  
setData(format:String, data:Object, serializable:Boolean = true):Boolean
加入要以指定資料格式進行傳輸的資訊形式。
Clipboard
  
setDataHandler(format:String, handler:Function, serializable:Boolean = true):Boolean
將參考加到處理常式函數 – 它負責產生傳送時所需的資料。
Clipboard
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
屬性詳細資訊

formats

屬性
formats:Array  [唯讀]

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

字串陣列,內含此 Clipboard 物件中可用的資料格式名稱。

具有標準格式名稱的字串常數是在 ClipboardFormats 類別中定義。要傳輸的資料為物件時,應用程式定義的其他字串也可以當做格式名稱使用。



實作
    public function get formats():Array

相關 API 元素


範例  ( 如何使用本範例 )
下列程式碼將讀取系統剪貼簿的 formats 陣列:
 var availableFormats:Array = Clipboard.generalClipboard.formats;

generalClipboard

屬性 
generalClipboard:Clipboard  [唯讀]

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

作業系統剪貼簿。

任何貼至系統剪貼簿中的資料都可以供其他應用程式使用,其中可能包含在網頁瀏覽器中執行的不安全遠端程式碼。

注意:在 Flash Player 10 應用程式中,必須先有使用者事件 (例如「貼上」命令的鍵盤快速鍵,或在快顯選單的「貼上」命令上按下滑鼠),才能進行從剪貼簿貼上的作業。只有當 InteractiveObject 已經收到並開始處理貼上事件時,Clipboard.getData() 才會傳回剪貼簿內容。在任何其他情況下呼叫 Clipboard.getData() 都不會成功。在 AIR 中,相同的限制也適用於應用程式安全執行程序之外的內容。

generalClipboard 物件會自動建立,您無法將 Clipboard 的其他實體指派給此屬性。因此,請改用 getData()setData() 方法,對現有的物件讀取和寫入資料。

您一定要先清除剪貼簿,再於其中寫入新的資料,如此可確保已消除所有格式的舊資料。

generalClipboard 物件不能傳遞給 AIR NativeDragManager。建立新的 Clipboard 物件供 AIR 應用程式的原生拖放作業使用。



實作
    public static function get generalClipboard():Clipboard

範例  ( 如何使用本範例 )
若要寫入作業系統剪貼簿:
 import flash.desktop.ClipboardFormats;
 
 var copy:String = "A string to copy to the system clipboard.";
 Clipboard.generalClipboard.clear();
 Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, copy);
若要讀取作業系統剪貼簿:
 import flash.desktop.ClipboardFormats;
 
 var pasteData:String  = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT) as String;
    

supportsFilePromise

屬性 
supportsFilePromise:Boolean  [唯讀]

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

指出用戶端系統是否支援檔案承諾剪貼簿格式。



實作
    public function get supportsFilePromise():Boolean
建構函式詳細資料

Clipboard

()建構函式
public function Clipboard()

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

建立空的 Clipboard 物件。

建立 Clipboard 物件保存在 Adobe AIR 中原生拖放手勢的資料。Clipboard 物件只能用於一個拖放手勢,無法重複使用。

請勿建立 Clipboard 物件用於複製與貼上作業。請改為使用單一 Clipboard.generalClipboard 物件。


擲回值
IllegalOperationError — Flash Player 不支援 new Clipboard(),因為 Flash Player 只能使用作業系統的剪貼簿。針對作業系統剪貼簿中涉及的複製與貼上作業,請使用 Clipboard.generalClipboard 物件,而非建立新的 Clipboard 物件。不會在 AIR 應用程式中擲回錯誤。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼將建立新的剪貼簿以搭配 NativeDragManager 類別使用。

注意:針對作業系統剪貼簿中涉及的複製與貼上作業,請使用 Clipboard.generalClipboard 物件,而非建立新的剪貼簿。

 import flash.desktop.Clipboard;
 
 var clipboard:Clipboard = new Clipboard();
方法詳細資訊

clear

()方法
public function clear():void

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

刪除此 Clipboard 物件中的所有資料形式。


擲回值
SecurityError — 本內容不允許呼叫 generalClipboard.clear()。在 Flash Player 中,只有在處理使用者事件 (例如,按下按鍵或按下滑鼠) 期間,才能成功呼叫這個方法。在 AIR 中,這項限制僅適用於應用程式安全執行程序外的內容。

範例  ( 如何使用本範例 )

下列程式碼將清除系統剪貼簿:
 Clipboard.generalClipboard.clear();

clearData

()方法 
public function clearData(format:String):void

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

刪除指定格式的資料形式。

參數

format:String — 要移除的資料格式。


擲回值
SecurityError — 本內容不允許呼叫 generalClipboard.clearData()。在 Flash Player 中,只有在處理使用者事件 (例如,按下按鍵或按下滑鼠) 期間,才能成功呼叫這個方法。在 AIR 中,這項限制僅適用於應用程式安全執行程序外的內容。

範例  ( 如何使用本範例 )

下列範例將清除系統剪貼簿中具有 ClipboardFormats.TEXT_FORMAT 格式的所有資料:
 import flash.desktop.ClipboardFormats;
 
 Clipboard.generalClipboard.clearData(ClipboardFormats.TEXT_FORMAT);

getData

()方法 
public function getData(format:String, transferMode:String = "originalPreferred"):Object

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

如果存在指定格式的資料,則取回剪貼簿資料。

Flash Player 需要在 paste 事件處理常式中呼叫 getData() 方法。在 AIR 中,這項限制僅適用於應用程式安全執行程序外的內容。

存取標準資料格式時,此資料會當作新的物件 (其類型為對應的 Flash 資料類型) 傳回。

存取應用程式定義的格式時,transferMode 參數會判斷傳回的是原始物件的參考,還是包含原始物件之已序列化副本的匿名物件。指定 originalPreferredclonePreferred 模式時,如果沒有偏好使用的版本,Flash Player 或 AIR 將傳回替代版本。指定 originalOnlycloneOnly 模式時,如果無法使用要求的版本,Flash Player 或 AIR 將傳回 null

參數

format:String — 要傳回的資料格式。此格式字串可包含 ClipboardFormats 類別內定義的其中一個標準名稱,或應用程式定義的名稱。
 
transferMode:String (default = "originalPreferred") — 指定在存取應用程式定義的資料格式時,要傳回參考還是已序列化的副本。此值必須是在 ClipboardTransferMode 類別內定義的其中一個名稱:若為標準資料格式,此值會遭忽略。系統一律會傳回副本。

傳回值
Object — 其類型對應至該資料格式的物件。

擲回值
Error transferMode 不是 ClipboardTransferMode 類別中定義的名稱之一。
 
IllegalOperationError — 要求的 Clipboard 物件已經不在範圍內 (僅限 AIR)。
 
SecurityError — 在此情況下,不允許從剪貼簿讀取,或是寫入剪貼簿。在 Flash Player 中,您只能在處理 paste 事件時,成功呼叫此方法。在 AIR 中,這項限制僅適用於應用程式安全執行程序外的內容。

相關 API 元素


範例  ( 如何使用本範例 )

下列範例將從系統剪貼簿讀取文字 (如果有的話):
 import flash.desktop.ClipboardFormats;

 var pasteData:String = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT) as String;

hasFormat

()方法 
public function hasFormat(format:String):Boolean

語言版本: ActionScript 3.0
執行階段版本: Flash Player 10, AIR 1.5

檢查此 Clipboard 物件中是否存在指定之格式的資料。

您可以使用 ClipboardFormats 類別中的常數來參考標準格式名稱。

參數

format:String — 要檢查的格式類型.

傳回值
Booleantrue 表示存在指定之格式的資料。

擲回值
IllegalOperationError — 要求的 Clipboard 物件已經不在範圍內。
 
SecurityError — 在此情況下,不允許從剪貼簿讀取,或是寫入剪貼簿。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼將測試系統剪貼簿,判斷是否有格式為文字的資料:
if(Clipboard.generalClipboard.hasFormat(ClipboardFormats.TEXT_FORMAT)){
    //do something 
}

setData

()方法 
public function setData(format:String, data:Object, serializable:Boolean = true):Boolean

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

加入要以指定資料格式進行傳輸的資訊形式。

在 Adobe AIR 的執行程序中,可以隨時呼叫 setData()。在其他情況中,只有在回應使用者事件 (例如,按下某個按鍵或滑鼠),才可以呼叫 setData()

同一個資訊的不同形式可以使用不同格式加入剪貼簿中,如此可提高其他組件或應用程式使用該可用資料的機會。例如,您可以加入影像做為點陣圖資料供影像編輯應用程式使用,或是做為 URL 使用,以及做為已編碼的 PNG 檔案供傳輸至原生檔案系統。

data 參數必須是指定之格式的適當資料類型:

格式類型說明
ClipboardFormats.TEXT_FORMAT字串字串資料
ClipboardFormats.HTML_FORMAT字串HTML 字串資料
ClipboardFormats.URL_FORMAT字串URL 字串 (僅限 AIR)
ClipboardFormats.RICH_TEXT_FORMATByteArrayRTF 格式資料
ClipboardFormats.BITMAP_FORMATBitmapData點陣圖資料 (僅限 AIR)
ClipboardFormats.FILE_LIST_FORMATFile 的陣列以及檔案陣列 (僅限 AIR)
自訂格式名稱任何物件參考和已序列化的副本

自訂格式的名稱不能以「air:」或「flash:」做為開頭。使用自訂格式時若要避免命名衝突,您可以使用自己的應用程式 ID 或套件名稱做為格式的前置詞,例如「com.example.applicationName.dataPacket」。

在 應用程式內部或之間進行傳輸時,serializable 參數可以決定物件的參考和副本都可用,還是只有參考可用。將 serializable 設定為 true 表示資料物件的參考和副本都可用;將 serializable 設定為 false 表示只有物件參考可用。由於物件參考只有在目前的應用程式中才有效,因此將 serializable 設定為 false 也表示其他 Flash Player 或 AIR 應用程式將無法使用該格式的資料。存取該格式的資料時,藉由設定適當的剪貼簿傳輸模式,組件便可以選擇要取得該物件的參考還是副本。

注意:在支援的應用程式外面貼上或拖曳資料時,這些標準格式一定會轉換為原生格式,因此 serializable 參數的值不會讓非 Flash 應用程式無法使用標準格式的資料。

若要延遲顯示某種格式的資料,請改用 setDataHandler() 方法。如果使用 setData()setDataHandler() 方法加入具有相同的格式名稱的資料形式,則永遠不會呼叫該處理常式函數。

注意:在 Mac OS 上,當您將 format 參數設定成 ClipboardFormats.URL_FORMAT 時,只有 URL 有效時才會予以傳送。否則,Clipboard 物件會被清空 (並呼叫 getData() 來傳回 null)。

參數

format:String — 資料的格式。
 
data:Object — 要加入的資訊。
 
serializable:Boolean (default = true) — 對於可以序列化 (和還原序列化) 的物件,請指定 true

傳回值
Booleantrue 表示資料已成功設定,否則為 false。在 Flash Player 中,當 ClipboardFormats 不支援 format 成員時,會傳回 false (Flash Player 不支援 ClipboardFormats.URL_FORMATClipboardFormats.FILE_LIST_FORMATClipboardFormats.FILE_PROMISE_LIST_FORMATClipboardFormats.BITMAP_FORMAT)。

擲回值
IllegalOperationError — 要求的 Clipboard 物件已不在範圍中 (為拖放作業建立剪貼簿時會發生此情況)。
 
SecurityError — 在此情況下,不允許從剪貼簿讀取,或是寫入剪貼簿。在 Flash Player 中,只有在處理使用者事件 (例如,按下按鍵或按下滑鼠) 期間,才能成功呼叫這個方法。在 AIR 中,這項限制僅適用於應用程式安全執行程序外的內容。
 
TypeError formatdatanull

相關 API 元素


範例  ( 如何使用本範例 )

下列範例會以文字和 HTML 格式,將內容加入系統剪貼簿:
 import flash.desktop.ClipboardFormats;
 
 var htmlString:String = "<html><body>Body content</body></html>";
 Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, urlString);
 Clipboard.generalClipboard.setData(ClipboardFormats.HTML_FORMAT, urlString);

setDataHandler

()方法 
public function setDataHandler(format:String, handler:Function, serializable:Boolean = true):Boolean

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

將參考加到處理常式函數 – 它負責產生傳送時所需的資料。

您可以使用此處理常式函數,延遲建立或顯示資料,直到實際存取該資料為止。

處理常式函數必須傳回指定之格式的適當資料類型:

格式傳回類型
ClipboardFormats.TEXT_FORMAT字串
ClipboardFormats.HTML_FORMAT字串
ClipboardFormats.URL_FORMATString (僅限 AIR)
ClipboardFormats.RICH_TEXT_FORMATByteArray
ClipboardFormats.BITMAP_FORMATBitmapData (僅限 AIR)
ClipboardFormats.FILE_LIST_FORMATFile 的陣列 (僅限 AIR)
ClipboardFormats.FILE_PROMISE_LIST_FORMATFile 的陣列 (僅限 AIR)
自訂格式名稱非 void

只有在已讀取指定之格式的資料時,才會呼叫此處理常式函數。注意:在某些情況下,作業系統會在放置之前,先呼叫此函數。例如,當您使用 handler 函數,為從 AIR 應用程式拖曳至檔案系統的檔案提供資料,作業系統會在拖曳手勢離開 AIR 應用程式時,立即呼叫資料處理常式 — 通常會在資料下載和建立時,造成意外的暫停。您可以使用 URLFilePromise 得到相同的結果。

請注意,除非您的應用程式採取保護資料的步驟,否則在加入處理常式和讀取資料之間,基礎資料可能會變更。在處理常式函數所表示之剪貼簿上的資料讀取一次以上時所發生的行為指令,並不保證一定會發生。剪貼簿可能會傳回第一個函數呼叫所產生的資料,或者可能會再次呼叫此函數。請勿依賴任何一個行為指令。

在 Adobe AIR 的執行程序中,可以隨時呼叫 setDataHandler()。在其他情況中,只有在回應使用者事件 (例如,按下某個按鍵或滑鼠),才可以呼叫 setDataHandler()

若要直接將資料加入 Clipboard 物件,請改用 setData() 方法。如果使用相同的格式名稱呼叫 setData()setDataHandler() 方法,則永遠都不會呼叫該處理常式函數。

注意:在 Mac OS 上,當您將 format 參數設定成 ClipboardFormats.URL_FORMAT,只有在處理常式函數傳回有效 URL 時,才會傳回 URL。否則,Clipboard 物件會被清空 (並呼叫 getData() 來傳回 null)。

參數

format:String — 函數,可傳回要傳輸的資料。
 
handler:Function — 資料的格式。
 
serializable:Boolean (default = true) — 如果 handler 傳回的物件可以序列化 (和還原序列化),請指定 true

傳回值
Booleantrue 表示處理常式已成功設定,否則為 false

擲回值
TypeError formathandlernull
 
IllegalOperationError — 要求的 Clipboard 物件已經不在範圍內 (僅限 AIR)。
 
SecurityError — 在此情況下,不允許從剪貼簿讀取,或是寫入剪貼簿。在 Flash Player 中,只有在處理使用者事件 (例如,按下按鍵或按下滑鼠) 期間,才能成功呼叫這個方法。在 AIR 中,這項限制僅適用於應用程式安全執行程序外的內容。

相關 API 元素

setData()
flash.desktop.ClipboardFormats
flash.desktop.URLFilePromise

範例  ( 如何使用本範例 )

下列程式碼會透過延遲的資料函數,將隨機號碼加入系統剪貼簿:
 import flash.desktop.ClipboardFormats;
 
 Clipboard.generalClipboard.setDataHandler(ClipboardFormats.TEXT_FORMAT, randomNumberGenerator);

 public function randomNumberGenerator():String{
     return Math.random().toString();
 }
ClipboardExample.as

下列 Adobe AIR 範例,將使用 ClipboardExample 類別,透過系統剪貼簿從某個變數將一字串複製到其他變數。您可以執行下列步驟來完成這項工作:
  1. 將資料 (在此例中為字串) 寫入 Clipboard.generalClipboard
  2. Clipboard.generalClipboard 讀取剪貼簿內容。

注意:因為存取剪貼簿資料會有安全方面的限制,所以此範例在 Flash Player 中無效。在 Flash Player 中,您只可以在 paste 事件處理常式中,呼叫 Clipboard 物件的 getData() 方法。

package
{
    import flash.display.Sprite;
    import flash.desktop.Clipboard;
    import flash.desktop.ClipboardFormats;
    import flash.desktop.ClipboardTransferMode;

    public class ClipboardExample extends Sprite
    {
        public function ClipboardExample()
        {
            var sally:String = "Sally";
            var person:String;
            
            copy(sally);
            person = paste();
            trace(person); //traces: "Sally"
        }

        private function copy(text:String):void 
        {
            Clipboard.generalClipboard.clear();
            Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, text);
        }
        
        private function paste():String
        {
            if(Clipboard.generalClipboard.hasFormat(ClipboardFormats.TEXT_FORMAT))
            {
                return String(Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT));
            } 
            else 
            {
                return null;
            }
        }
        
    }
}




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

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