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

107 Views Asked by At

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 ..

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.

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

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.

Thank you in advance for your help.

1

There are 1 best solutions below

0
On

Try to create complete TextFlow without using TextConverter.importToFlow. 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.