Just to be clear, in order for System.setClipboard() to work, it has to be executed within a function that receives either a Keyboard or Mouse Event. Now, in my specific case, I need to hack this so that when I press ‘enter’, I get my string that I want to paste into the clipboard from the internet, and when Flash gets it, THEN it pastes it in.
Here’s an example on how I thought I could do that (unfortunately I didn’t work).
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyboardHandler);
function keyboardHandler(e:KeyboardEvent):void {
switch (e.charCode) {
// ENTER key
case 13:
getStringFromInternet(e);
// The lower code will work, but I can't run it because I don't yet have my string, so I have to call this in delayedClipboard();
//System.setClipboard("It works! But not as I want it to.");
break;
};
};
function getStringFromInternet(e):void {
// do some stuff, then set the clipboard with delayedClipboard()
delayedClipboard(e);
}
function delayedClipboard(e):void {
System.setClipboard("It works!");
}