Pacoteflash.desktop
Classepublic class Clipboard
HerançaClipboard Inheritance Object

Provides a container for transferring data and objects through the clipboard and through drag-and-drop operations.

A Clipboard object may contain the same information in more than one format. By supplying information in multiple formats, you increase the chances that another application will be able to use that information. Add data to a Clipboard object with the setData() method.

The standard formats are:

The standard formats are automatically translated between ActionScript data types and the native clipboard when a transfer between an AIR application and the operating system occurs. The ClipboardFormats class defines string constants for the standard format names.

You can use application-defined formats to add ActionScript objects to a Clipboard object. If an object is serializable, both a reference and a clone of the object can be made available. Object references are only valid within the originating application.

When it is computationally expensive to convert the information to be transferred into a particular format, you can supply the name of a function that will perform the conversion if and only if that format is read by the receiving component or application. Add a deferred rendering function to a Clipboard object with the setDataHandler() method.

Veja também

flash.desktop.DragManager
flash.desktop.ClipboardFormats
flash.desktop.ClipboardTransferMode


Propriedades Públicas
 PropriedadeDefinido por
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  formats : Array
[read-only] An array of strings containing the names of the data formats available in this Clipboard object.
Clipboard
  generalClipboard : Clipboard
[static] [read-only]
Clipboard
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Métodos Públicos
 MétodoDefinido por
  
Creates an empty Clipboard object.
Clipboard
  
Deletes all data representations from this clipboard object.
Clipboard
  
Deletes the data representation for the specified format.
Clipboard
  
dataForFormat(format:String, transferMode:String):Object
Clipboard
  
getData(format:String, transferMode:String):Object
Gets the data in the specified format.
Clipboard
  
Checks whether data in the specified format exists in this Clipboard object.
Clipboard
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
setData(format:String, data:Object, serializable:Boolean = true):Boolean
Adds a representation of the information to be transferred in the specified data format.
Clipboard
  
setDataHandler(format:String, handler:Function, serializable:Boolean = true):Boolean
Adds a reference to a handler function that produces the data for the specified format on demand.
Clipboard
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Detalhes da propriedade
formatspropriedade
formats:Array  [read-only]

An array of strings containing the names of the data formats available in this Clipboard object.

String constants for the names of the standard formats are defined in the ClipboardFormats class. Other, application-defined, strings may also be used as format names when the data to be transferred is an object.


Implementação
    public function get formats():Array

Veja também

generalClipboardpropriedade 
generalClipboard:Clipboard  [read-only]
Implementação
    public static function get generalClipboard():Clipboard
Detalhes do construtor
Clipboard()Construtor
public function Clipboard()

Creates an empty Clipboard object.

Detalhes do método
clear()método
public function clear():void

Deletes all data representations from this clipboard object.

clearData()método 
public function clearData(format:String):void

Deletes the data representation for the specified format.

Parâmetros

format:String — The data format to remove.

dataForFormat()método 
public function dataForFormat(format:String, transferMode:String):Object

Parâmetros

format:String
 
transferMode:String

Retorna
Object
getData()método 
public function getData(format:String, transferMode:String):Object

Gets the data in the specified format.

When a standard data format is accessed, the data is returned as a new object of the corresponding AIR type.

When an application-defined format is accessed, the value of the transferMode parameter determines whether a reference to the original object or an anonymous object containing a serialized copy of the original object is returned.

When one of the "preferred" modes is specified, AIR will return the alternate version when the preferred version is not available. When one of the "only" modes is specified, AIR will return undefined when the desired version is not available.

Parâmetros

format:String — the data format to return. The format string can contain one of the standard names defined in the ClipboardFormats class, or an application-defined name.
 
transferMode:String — specifies whether to return a reference or serialized copy when an application-defined data format is accessed. The value must be one of the names defined in the ClipboardTransferMode class. This value is ignored for the standard data formats.

Retorna
Object — an object of the type corresponding to the data format

Veja também

hasFormat()método 
public function hasFormat(format:String):Boolean

Checks whether data in the specified format exists in this Clipboard object.

Use the constants in the ClipboardFormats class to help check for the presence of data in the standard formats.

Parâmetros

format:String — The format type to check

Retorna
Booleantrue, if data in the specified format is present.

Veja também

setData()método 
public function setData(format:String, data:Object, serializable:Boolean = true):Boolean

Adds a representation of the information to be transferred in the specified data format.

Different representations of the same information can be added in different formats to increase the ability of other components or applications to make use of the available data. For exemplo, an image could be added as bitmap data for use by image editing applications, as a Bitmap object for use by other AIR applications, and as an encoded .png file for transfer to the native file system.

The data parameter must be the appropriate data type for the specified format:

FormatTypeDescrição
ClipboardFormats.TEXT_FORMATStringstring data
ClipboardFormats.URL_FORMATStringURL string
ClipboardFormats.BITMAP_FORMATBitmapDatabitmap data
ClipboardFormats.FILE_LIST_FORMATarray of Filean array of files
Custom format nameanyobject reference and serialized clone

Custom format names cannot begin with "air:" or "flash:". To prevent format naming collisions when using custom formats, you may wish to use your application ID or a package name as a prefix to the format, such as, "com.exemplo.applicationName.dataPacket".

When transferring within or between AIR applications, the serializable parameter determines whether both a reference and a copy are available, or whether only a reference to an object is available. Set serializable to true to make both the reference and a copy of the data object available. Set serializable to false to make only the object reference available. Object references are only valid within the current application so setting serializable to false will also mean that the data in that format will not be available to other AIR applications. A component can choose to get the reference or the copy of the object by setting the appropriate ClipboardTransferMode when accessing the data for that format.

Note: the standard formats are always converted to native formats when data is pasted or dragged outside an AIR application, so the value of the serializable parameter does not affect the availability of data in the standard formats to non-AIR applications.

To defer rendering of the data for a format, use the setDataHandler() method instead. If both the setData() and the setDataHandler() methods are used to add a data representation with the same format name, then the handler function will never be called.

Parâmetros

format:String — The information to add.
 
data:Object — The format of the data.
 
serializable:Boolean (default = true) — Specify true for objects that can be serialized (and deserialized).

Retorna
Booleantrue if the data was succesfully set; false otherwise.

Throws
Error — If data is undefined.

Veja também

setDataHandler()método 
public function setDataHandler(format:String, handler:Function, serializable:Boolean = true):Boolean

Adds a reference to a handler function that produces the data for the specified format on demand. Use this method to defer creation or rendering of the data until it is actually accessed.

The handler function must return the appropriate data type for the specified format:

FormatReturn Type
ClipboardFormats.TEXT_FORMATString
ClipboardFormats.URL_FORMATString
ClipboardFormats.BITMAP_FORMATBitmapData
ClipboardFormats.FILE_LIST_FORMATArray of File
Custom format namenon-void

The handler function will be called when and only when the data in the specified format is read. Note that the underlying data can change between time the handler is added and the time the data is read unless your application takes steps to protect the data. The handler function will be called only once. Subsequent accesses will return the data produced by the first function call.

To add data directly to this Clipboard object, use the setData() method instead. If both the setData() and the setDataHandler() methods are called with the same format name, then the handler function will never be called.

Parâmetros

format:String — A function that returns the data to be tranfered when called.
 
handler:Function — The format of the data.
 
serializable:Boolean (default = true) — Specify true if the object returned by handler can be serialized (and deserialized).

Retorna
Booleantrue if the handler was succesfully set; false otherwise.

Throws
Error — If data is undefined.

Veja também