开发者

Paste rich text into Flash?

开发者 https://www.devze.com 2023-01-19 19:17 出处:网络
Is it possible to capture rich text when pasting into Flash? Using a Flex TextEditArea, I ca开发者_StackOverflown paste richly formatted text within Flash itself, but if I try to paste from an externa

Is it possible to capture rich text when pasting into Flash? Using a Flex TextEditArea, I ca开发者_StackOverflown 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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消