Hi,
I’ve searched a bit, but haven’t found what I need specifically.
I have an in-house application that is populating several HTML rows with text that needs to be copied. I already have that text being sent to my flash movie as a variable via Javascript. I also have a button that when clicked will copy those formatted lines of text in the method required for pasting into a different, unrelated application. The button method for
System.setClipboard(myTextField)
works just fine.
However, per “instructions” I need to establish a keyboard shortcut that fires the same “setClipboard” action. Currently, I am using External Reference to apply a javascript key combo capture that attempts to call the function within the Flash movie to set the clipboard. However, placing that setClipboard inside of the function called via javascript doesn’t work. The setClipboard action only seems to work when attached to the button.
I know there are restrictions with the newer flash player requiring user interaction with the movie to access the clipboard, but is there any way to simulate the button click or package the setClipboard action in a function that will allow this to work? This is an in-house application so the actual security issues are not as prevalent.
Hopefully this explanation made sense…any help would be appreciated.
This is what I have in place currently. I know the javascript communication works, as I have been able to send commands such as:
_root.play();
inside of the function in the flash movie. It’s just the “setClipboard” portion that doesn’t take place.
Flash movie:
import flash.external.*;
// The name of the Flash variable to be called in JavaScript
var flashFunction:String = "callJsCopy";
var instance:Object = null;
// Callback function executed by the name of variable
var realFunction:Function = jsTxtCopy;
ExternalInterface.addCallback(flashFunction, null, realFunction);
function jsTxtCopy():Void{
//_root.play();
System.setClipboard(txtblock);
};
//txtblock.html = true;
var textblock = "Select the checkboxes of the lines you wish to copy.";
txt.text=textblock;
//button action setting clipboard from selcted text areas on HTML page.
buttonA.onRelease = function() :Void{
System.setClipboard(txtblock);
};
stop();
Javascript on HTML Page:
<script type="text/javascript">
function callExternalInterface() {
/* Call a function registered as callJsCopy in the SWF named textCopy. */
getMovieName("textCopy").callJsCopy();
}
/* This utility function resolves the string movieName to a Flash object reference based on browser type. */
function getMovieName(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
var isCtrl = false;
document.onkeyup=function(e){
if(e.which == 17) isCtrl=false;
}
document.onkeydown=function(e){
if(e.which == 17) isCtrl=true;
if(e.which == 16 && isCtrl == true) {
callExternalInterface();
//alert("CTRL + SHIFT");
}
}
</script>