Sunday, April 17, 2011

Working with clipboard in AIR: Part 4

In today's tutorial we'll learn about the different ways of passing our clipboard data.

There are two main situations where you would want to use clipboard: the first one is transferring data just inside your AIR application, and the second one is transferring data between your AIR application and the system clipboard, making your data available to other programs, therefore, transferring data between your AIR application and programs outside of it.

When you are dealing with the second situation, the data we have in clipboard is stored there as a copy of the initial data. This means we can close our AIR application after saving stuff to our clipboard and still have the data in our clipboard and we can still transfer the data to other applications.

When you're dealing with transferring data just inside of your AIR application, it is possible to pass the data as a reference, not as an actual value (copy of the initial data). This means that in the second situation we'd have an additonal copy of the same data in our clipboard, while in the first situation we can simply redirect to the already existing piece of data - the original copy.

By default, when writing data to the clipboard, an actual new copy is created, not a reference. You can manually control the process and only include a reference to the original copy of the data by setting the third parameter of setData to 'false', and if you want to include the copy and the reference in the clipboard, set it to 'true'.

You can also tell AIR how to read the data. You can set the second parameter of getData() to the method of receiving the data. Possible parameters are: ORIGINAL_PREFERRED - returns the reference to the data, if there's no reference - returns the clone; ORIGINAL_ONLY - returns the reference, if there's no such reference - returns null; CLONE_PREFERED - returns the clone, if there is not clone, then return the reference; CLONE_ONLY - returns clone if available, if not - returns null.

That is all for now.

Thanks for reading!

Related:

Working with clipboard in AIR: Part 1
Working with clipboard in AIR: Part 2
Working with clipboard in AIR: Part 3
Working with clipboard in AIR: Part 5
Working with clipboard in AIR: Part 6
Working with clipboard in AIR: Part 7
Working with clipboard in AIR: Part 8
Working with clipboard in AIR: Part 9
Working with clipboard in AIR: Part 10

No comments:

Post a Comment