views:

41

answers:

2

Is it possible to capture rich text when pasting into Flash? Using a Flex TextEditArea, I can paste richly formatted text within Flash itself, but if I try to paste from an external source (say web page, microsoft word, etc) it comes in as plain text. Same for the reverse: if I copy rich text from within Flash, and paste to an external source, it goes out as plain text.

A: 

have a look at TinyMCE or some other editor, they have options for pasting word text, perhaps you might be able look at how their parsing it and emulate that. If you can target flex4 flash player 10 you might have a look at http://labs.adobe.com/technologies/textlayout/ which might help you as this post on adobes forums states

dstarh
TinyMCE is for Javascript, it uses the browser's built in ability to handle HTML, I don't think that will help me. I am actually using Flex 4 and a TLF-based text editor, so I'll look at those links, thanks.
davr
The first link just is a generic info page about TLF, the second link talks about flash 9 / flex 3, and says it's not possible in that case. But I am using flash 10 / flex 4, so trying to figure out how to do it.
davr
I know TinyMCE is for javascript but my thought was that tinyMCE is parsing the text that comes from word and formatting it to get rid of any word nastiness.
dstarh
Perhaps this forum post might help
dstarh
+1  A: 

I'm part way there, so far I've got this:

<s:RichEditableText paste="pasteHandler(event)" width="100%" height="100%"/>

 

protected function pasteHandler(event:Event):void
{               
    if(Clipboard.generalClipboard.hasFormat(ClipboardFormats.HTML_FORMAT)) {
        var txt:RichEditableText = event.target as RichEditableText;                    
        var html:String = Clipboard.generalClipboard.getData(ClipboardFormats.HTML_FORMAT) as String;
        var mgr:EditManager = txt.textFlow.interactionManager as EditManager;

        mgr.pasteTextScrap(new TextScrap(TextConverter.importToFlow(html, TextConverter.TEXT_FIELD_HTML_FORMAT)));

        event.stopImmediatePropagation();
    }
}

It gets some formatting in. But now there's a problem with font size -- anything that's not a default font size, is extremely tiny. Normal font stays normal. Large fonts become tiny fonts. Small fonts become 1-pixel high dots.

davr