comments (2) Views: 10,992
The first thing we need to do is to create a new reference to the clipboard. In AIR, there are two types of clipboard: the system clipboard, and the AIR clipboard. We'll only concern ourselves with the system clipboard for now.
// create a new clipboard object, a static value var cb = air.Clipboard.generalClipboard;
Now that we have a new clipboard object, we need to import the available clipboard formats. There are currently 6 static values, but again we'll only be concerning ourselves with one of them...TEXT_FORMAT
// retrieve the value for text formatted clipboard values var cbFormat = air.ClipboardFormats.TEXT_FORMAT;
Finally, we set our string to the clipboard
// set the string data into the clipboard cb.setData(cbFormat,myString);
It's a pretty simple process
// the original string var myString = 'AIR is great!'; // create a new clipboard object, a static value var cb = air.Clipboard.generalClipboard; // retrieve the value for text formatted clipboard values var cbFormat = air.ClipboardFormats.TEXT_FORMAT; // set the string data into the clipboard cb.setData(cbFormat,myString);
Look for more one-off AIR tips as I work through adding features to Shrinkadoo. Also, make sure to check out copy and paste in Shrinkadoo, coming soon.
If this article was interesting, or helpful, or even wrong, please consider leaving a comment, or buying something from my wishlist. It's appreciated!