apache-flexhtmltext

Unable to access embedded images in htmlText


Images can be included in TextArea controls using the htmlText property:

ta.htmlText = '<img src="http://..."/>';

How can I reference embedded images?

An example:

<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
            [Embed(source='../assets/img.gif')]
            public var img:Class;
        ]]>
    </mx:Script>
    <mx:htmlText>
        <![CDATA[
            <img src="???" />
        ]]>
    </mx:htmlText>
</mx:TextArea>

UPD:

<img src='../assets/img.gif />

works on local machine, but in server environment it throws:

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

How can I fix this?


Solution

  • Try:

    <mx:htmlText>
            <![CDATA[
               <p>
                <img src='../assets/butterfly.gif' 
                     width='30' height='30' 
                     align='left' 
                     hspace='10' vspace='10'>
                </p>
            ]]>
         </mx:htmlText>
    

    See documentation.