Copy a text from Flash to to the sytem clipboard
A neat series of examples on ActionScript.org
<html>
<head>
<title>Flash To Clipboard</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="Javascript">
<!--
// Flash to Clipboard
// By drZoode (zoode@usa.net)
// IE 4 and above specific execCommand methods
// are used to get access to the clipboard
// the innerText property of a hidden textarea (id="hiddenBox")
// is used to manipulate the text range
function flashToClipBoard(flashInput) {
// the argument of this function is passed from Flash
myForm.hiddenBox.innerText = flashInput;
copiedText = myForm.hiddenBox.createTextRange();
copiedText.execCommand("Copy");
pastedText = myForm.pasteHere.createTextRange();
pastedText.execCommand("Paste");
}
function clipBoardToFlash() {
pastedText = myForm.pasteHere.createTextRange();
pastedText.execCommand("Paste");
var goToFlash = myForm.pasteHere.innerText;
// we use a Flash Method to *simulate* the pasting effect
// as this is a IE only exercise we do not care for Netscape friendly syntax
window.movie.SetVariable("_root.text", goToFlash);
}
//-->
</script>
</head>
<body bgcolor="#999999" text="#000000">
<form id="myForm">
<table width="600" border="0" cellspacing="5" cellpadding="5">
<tr>
<td>
<textarea rows="10" cols="50" id="hiddenBox" style="display:none" name="textarea">
</textarea>
</td>
</tr>
<tr>
<td>
<p>The text in the clipboard will appear here.
<br>You can open a text editor program (e.g. Notepad) and paste the text there.</p>
</td>
</tr>
<tr>
<td>
<textarea rows="6" cols="40" id="pasteHere" name="textarea2">
</textarea>
</td>
</tr>
</table>
<br>
<br>
</form>
[Flash embed]
<p> NOTE: If the text you have copied in Flash has carriage returns you cannot copy it back to the clipboard.
<p><b>Here is some text that you can copy to the clipboard</b>
<br>(Choose Edit>Copy or right-click and copy).
<br>
<br>'Twas brillig, and the slithy toves
<br>Did gyre and gimble in the wabe:
<br>All mimsy were the borogoves,
<br>And the mome raths outgrabe.
<br><br>
<button onClick = "clipBoardToFlash()">Paste to Flash </button>
</p>
</body>
</html>
0 Comments:
Posta un commento
<< Home