将丰富的文本粘贴到Flash中? [英] Paste rich text into Flash?
问题描述
粘贴到Flash中时可以捕获丰富的文本吗?使用Flex TextEditArea,我可以在Flash本身中粘贴丰富格式的文本,但是如果我尝试从外部源(比如说网页,微软等)粘贴,它会以纯文本的形式出现。相反,如果我从Flash中复制丰富的文本,并粘贴到外部源,它将以纯文本的形式出现。
< 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作为RichEditableText;
var html:String = Clipboard.generalClipboard.getData(ClipboardFormats.HTML_FORMAT)as String;
var mgr:EditManager = txt.textFlow.interactionManager作为EditManager;
mgr.pasteTextScrap(new TextScrap(TextConverter.importToFlow(html,TextConverter.TEXT_FIELD_HTML_FORMAT)));
event.stopImmediatePropagation();
$ / code $ / pre
它得到了一些格式化。但现在有一个问题与字体大小 - 任何不是默认的字体大小,是非常微小的。正常字体保持正常。大字体变成小字体。小字体变成1像素高点。
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.
解决方案 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.
这篇关于将丰富的文本粘贴到Flash中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!