Hi,
I’m trying to add an image at runtime to my textArea like this. But when i run the app, the textarea shows blank. Please help friends…
<mx:Script>
<![CDATA[
public function addImage(event:Event) : void
{
//file vim.png is present both in Project folder and in the src folder of the Project
txtarea.htmlText = "<img src='vim.png'>";
// txtarea.htmlText = "<img src=\"vim.png\">";
}
]]>
</mx:Script>
<mx:TextArea x="103" y="70" height="216" width="291" editable="false" wordWrap="true"
id="txtarea" creationComplete="addImage(event)"/>
I checked
http://www.actionscript.org/resources/articles/122/1/Loading-Images-Via-XML-into-Flash-MX-2004/Page1.html
but didnt help my cause.
Alternatively I tried following too. but this too didnt help
<mx:Script>
<![CDATA[
import mx.controls.Image;
import flash.net.URLLoaderDataFormat;
public function addImage(event:Event) : void
{
var loader : URLLoader = new URLLoader();
var request : URLRequest = new URLRequest("vim.png");
loader.load(request);
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE , showImage);
}
public function showImage(event : Event) : void
{
var loader : URLLoader = URLLoader(event.target);
txtarea.htmlText = loader.data;
}
]]>
</mx:Script>
<mx:TextArea x="103" y="70" height="216" width="291" editable="false" wordWrap="true"
id="txtarea" creationComplete="addImage(event)"/>