How do I copy RTF data from one TextArea to a clip board and copy it to another TextArea while presevering the formatting in Flex 3?

I have a text area that is display RTF data and I am including a "copy to clipboard button" so they can paste it directly into another text area. When I highlight the text a copy and paste it works, but when I try to do it from a button, it doesnt.

I have tried setting the textarea.htmltext but it doesnt seem to like it when its done through the system copy.

Can you point me in the right direction?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Flex is limited in it's programmable interaction with the clipboard. Yes it works when you e.g. press Ctrl-C to copy, but in Flex the only command you have for working with the clipboard is System.setClipboard, which only takes a string. What you copy via Ctrl-C is much more than a string.

The restriction is for security purposes - would you want a Flex app you might not trust copying object data to the clipboard?

Look at AIR for much better Clipboard interaction (with the Clipboard class) - when you allow AIR apps to run on your desktop a higher level of trust is implicitly assumed.

Only other option I can think of is to 'fake your own clipboard' in the following example, but I know this is not really what you want as you'd have to force the user to also use the 'Paste' button.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute">
			private var mockHTMLClipboard:String = "";
			private function onCopy():void
				mockHTMLClipboard = rte.htmlText; 
			private function onPaste():void
				ta.htmlText = mockHTMLClipboard;
	<mx:HBox width="100%" horizontalCenter="0" verticalCenter="0" horizontalAlign="center" height="332">
		<mx:VBox height="100%">
			<mx:Button label="Copy" id="btnCopy" click="onCopy();"/>
			<mx:RichTextEditor id="rte" title="Title">
		<mx:VBox height="100%">
			<mx:Button label="Paste" id="btnPaste" click="onPaste();"/>
			<mx:TextArea id="ta" height="100%" width="226"/>

Open in new window

Polite request for an update - please remember to close questions if your issue is resolved, or reply if you need further assistance ;)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
20lbMonkeyAuthor Commented:
This is a great answer and it helped me tremendously. Sorry that I didnt close it our earlier. I actually took a few days off for the holiday weekend.
Great - glad it helped, hope you got a good break !
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.