Copy, Cut, Paste
Hi,
How can I implement cupy, cut and paste in actionscript. Basically, I have 3 buttons that I want to use to trigger those actions.
Thanks in advance.
Hi,
How can I implement cupy, cut and paste in actionscript. Basically, I have 3 buttons that I want to use to trigger those actions.
Thanks in advance.
Are you going to run this from an AIR application, or from the Flash Player in a browser? In the latter case, there are security restrictions that prevent you from accessing the clipboard unless the browser has detected a user request for Cut, Copy, or Paste (e.g., a menu hit). In an AIR application, these restrictions are not an issue.
I'd suggest looking at the TextScrap and TextClipboard classes as well as the EditManager. The TextClipboard has basic functions for getting content to and from the system clipboard. The TextScrap is a data structure used for copy & paste that's essentially a snippet of text from within a TextFlow.
For Copy, you can do a CopyOperation, or you can just do this:
TextClipboard.setContents(TextScrap.createTextScrap(selectionState));
The selectionState indicates the range of text to be copied.
For Paste or Cut, easiest way is through the EditManager, assuming your textFlow's interactionManager is an EditManager:
EditManager(textFlow.interactionManager).pasteTextScrap(TextClipboard.getContents());
and
TextClipboard.setContents(EditManager(textFlow.interactionManager).cutTextScrap());
Hope this helps,
- robin
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.