2
A
回答
5
我已經得到了答案:
package
{
import flash.display.Sprite;
import flash.desktop.Clipboard;
import flash.desktop.ClipboardFormats;
import flash.desktop.ClipboardTransferMode;
import flash.events.*;
import flash.system.System;
public class ClipboardExample extends Sprite
{
public function ClipboardExample()
{
Clipboard.generalClipboard.clear();
copyButton.addEventListener(MouseEvent.MOUSE_UP, copyText);
}
private function copyText(e:MouseEvent):void
{
Clipboard.generalClipboard.clear();
System.setClipboard(myField.text);
messageField.text = "Copied!";
stage.addEventListener(Event.PASTE,paste); //Ctrl+V on stage
}
private function paste(e:Event):void
{
if(Clipboard.generalClipboard.hasFormat(ClipboardFormats.TEXT_FORMAT))
{
messageField.text = String(Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT));
}
}
}
}
0
Did you mean myTextField.text = copiedTextVariable ;?
+0
我想在舞臺或任何文本區域框中粘貼文本。 – 2012-01-16 09:11:44
0
我認爲這是你在找什麼:
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.system.System;
import flash.text.TextField;
import flash.text.TextFieldType;
public class SelectTextTest extends Sprite {
public function SelectTextTest() {
var tf:TextField = new TextField();
tf.x = 0;
tf.y = 0;
tf.width = 200;
tf.height = 200;
addChild(tf);
tf.wordWrap = true;
tf.type = TextFieldType.INPUT;
tf.text = "This is the text. Try to select";
tf.addEventListener(MouseEvent.CLICK, printCursorPosition);
}
private function printCursorPosition(event:MouseEvent):void {
var tf:TextField = TextField(event.target);
trace("caretIndex:", tf.caretIndex);
trace("selectionBeginIndex:", tf.selectionBeginIndex);
trace("selectionEndIndex:", tf.selectionEndIndex);
trace(tf.text.substring(tf.selectionBeginIndex, tf.selectionEndIndex));
System.setClipboard(tf.text.substring(tf.selectionBeginIndex, tf.selectionEndIndex));
}
}
}
+0
如何將複製的文本粘貼到文本區域? – 2012-01-16 09:19:31
0
自Flash Player 10,嵌入網站應用閃光僅僅能夠訪問到Clipboard.generalClipboard.getData()方法,當他們正在處理由用戶直接調度的PASTE事件時。
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard.html
注意:爲了避免該異常的安全性,該事件的目標必須是應用程序的階段對象。 我沒有在任何文檔中找到這些信息,它來自我自己的經驗。希望它有效
相關問題
- 1. 如何從剪貼板粘貼文本?
- 2. 文本粘貼中的R
- 3. 如何使用按鈕將剪貼板中的文本粘貼到選定的文本框中
- 4. Javascript?文檔粘貼事件 - 獲取粘貼的文本在FireFox
- 5. 如何修改粘貼的文本?
- 6. 如何在文本框當前光標中粘貼文本?
- 7. BAT腳本粘貼文本
- 8. 網站如何抑制粘貼文本?
- 9. 如何使用js粘貼文本行?
- 10. 修復粘貼的文本
- 11. 如何在NSOutlineView中剪切和粘貼NSTextFieldCell中的文本
- 12. 如何在MFC中限制文本框中的複製粘貼?
- 13. 在Python中複製和粘貼文本
- 14. 在多個文本框中粘貼serialnumber
- 15. 在Sublime Text中自動選擇粘貼的文本3
- 16. 創建剪切複製粘貼在as3
- 17. 從Word中的Excel中粘貼文本?
- 18. 在vim中,如何直觀地選擇以前粘貼的文本
- 19. 如何當我使用getTransferData(選擇DataFlavor.stringFlavor)一些文本從剪貼板粘貼一樣從剪貼板中的數據粘貼到文本區域
- 20. 粘貼文本到終端
- 21. tinymce粘貼文本顏色
- 22. VBA excel粘貼爲文本
- 23. 粘貼到文本區
- 24. 文本框粘貼問題
- 25. 在GWT中設置選定的文本(爲了使複製粘貼更容易)
- 26. 在React Component的文本框中複製文本的粘貼
- 27. NSTextView粘貼:當粘貼「foo」時,如何粘貼「bar」?
- 28. flex:如何防止在flex3文本輸入中粘貼(ctrl + V)?
- 29. 如何在swift中自動粘貼文本?
- 30. 如何在MongoDB shell中複製和粘貼文本
你試過簡單的Ctrl V嗎? – 2012-01-16 09:09:32
是的,但ctrl + v在閃存之外工作,如記事本,寫字板等。我想在舞臺或任何文本區域框中粘貼文本。 – 2012-01-16 09:10:56