简体   繁体   English

如何将来自外部SWF的符号用作TextArea中的图像?

[英]How to use a symbol from an external swf as image in TextArea?

I hope someone will be able to help here, so first of all though let's take a look at exactly what my problem is ... 我希望有人能够在这里提供帮助,因此尽管首先让我们看一下我的问题到底是什么...

I would have liked to insert a movieclip from an external swf into my textarea but I think it isn't as easy as I thought... because the Textarea,TextFlow components are unfortunately almost unusable to me in this respect .. 我本来想将来自外部SWF的动画片段插入到我的textarea中,但是我认为这并不像我想的那么容易...因为不幸的是,在这方面,Textarea,TextFlow组件几乎对我不可用..

I have read the API of Textarea and TextFlow , and I searched a lot on Google and some forums, but I have not found the solution to my problem. 我已经阅读了Textarea和TextFlow的API,并在Google和一些论坛上进行了很多搜索,但没有找到解决问题的方法。

I have found similar topics to this one like as : Using symbol from library in htmlText <img> tag in ActionScript 3 http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000322.html 我发现了与此主题类似的主题,例如: 在ActionScript 3 http://help.adobe.com/zh_CN/AS2LCR/Flash_10.0/help.html?content=00000322 中的htmlText <img>标记中的库中使用符号 。 html

I have tried several ways to refer to the symbol but to no avail... 我尝试了几种方法来引用该符号,但无济于事...

Here is my code : 这是我的代码:

[Bindable]
/**
 * The text which will be displayed 
 **/
public var pblMessages:String = "";

<s:TextArea id="pblArea" left="10" right="242" top="241" bottom="55" editable="false" textFlow="{TextConverter.importToFlow(pblMessages,TextConverter.TEXT_FIELD_HTML_FORMAT)}" valueCommit="pblAreaCommitHandler(event)"> </s:TextArea>

Method for adding new line : 添加新行的方法:

private function submitText(keyPress:Boolean=false) :void {
            if (pblInput.text=="") {
                pblInput.setFocus();
                return;
            }
            var format:ElementFormat = new ElementFormat();
            var fontDescription:FontDescription = new FontDescription("Arial");
            format.fontSize = 11;
            format.fontDescription = fontDescription;

            var s:String = pblInput.text;
            var re: RegExp = new RegExp("\r|\n","gi");
            s = s.replace(re,"");
            var inlineGraphicElement:InlineGraphicElement = new InlineGraphicElement();
            inlineGraphicElement.source = Smileys.smi_kiss;

            var p:ParagraphElement = new ParagraphElement();
            p.addChild(inlineGraphicElement);
                            //pblArea.textFlow.addChild(p);
            pblMessages += "<font color='#000000'>" + s + "</font><img src='assets/testmovie.swf#smi_kiss' width='20' height='20'/><br/>";
            pblInput.text="";
    }

If the smiley is displayed on the first frame in the swf, then it displayed (without symbol) too in the TextArea of course.. but I don't want to make 100 different swf file.. I'm quite sure that the smileys can be displayed by using symbols. 如果笑脸显示在swf的第一帧中,那么它当然也会在TextArea中显示(没有符号)..但是我不想制作100个不同的swf文件。.我很确定笑脸可以使用符号显示。

Thank you in advance for your help. 预先感谢您的帮助。

Try to create complete TextFlow without using TextConverter.importToFlow. 尝试不使用TextConverter.importToFlow创建完整的TextFlow。 After adding inlineGraphicElement to p, you should add a SpanElement to p, and then add text to SpanElement.text, and then assign a textFlow to pblArea.textFlow. 将inlineGraphicElement添加到p之后,应该将SpanElement添加到p,然后将文本添加到SpanElement.text,然后将textFlow分配给pblArea.textFlow。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM