# Load image in a TextArea

**URL:** <https://forum.kirupa.com/t/load-image-in-a-textarea/248349>\
**Category:** flash\
**Created:** [January 7, 2008, 12:03pm UTC](https://forum.kirupa.com/t/load-image-in-a-textarea/248349 "2008-01-07T12:03:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubs6](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@shubs6](https://forum.kirupa.com/u/shubs6)\
**Post date:** [January 7, 2008, 12:03pm UTC](https://forum.kirupa.com/t/load-image-in-a-textarea/248349/1 "2008-01-07T12:03:59Z")

</div>

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…

```auto

    <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](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

```auto

    <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)"/>

```
