# Unloading external images

**URL:** <https://forum.kirupa.com/t/unloading-external-images/309933>\
**Category:** Uncategorized\
**Created:** [May 28, 2010, 1:26am UTC](https://forum.kirupa.com/t/unloading-external-images/309933 "2010-05-28T01:26:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaotic1987](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@chaotic1987](https://forum.kirupa.com/u/chaotic1987)\
**Post date:** [May 28, 2010, 1:26am UTC](https://forum.kirupa.com/t/unloading-external-images/309933/1 "2010-05-28T01:26:22Z")

</div>

import flash.display.Loader;

stage.focus = myTextBox;

myButton.addEventListener(MouseEvent.CLICK, findTarget);

function findTarget(evt:MouseEvent):void  
{  
var writer:String;  
var tester = String(myTextBox.text).toLowerCase()  
var checker:Array = new Array(“a”, “b”, “c”);  
var answers:Array = new Array();  
answers[0] = “Thats A!”;  
answers[1] = “Thats B!”;  
answers[2] = “Thats C!”;

```
        var images:Array = new Array("a.jpg", "b.jpg", "c.jpg");

        for (var i:int = 0; i &lt; checker.length; i++)
        {
            if (tester == checker*)
            {
                  writer = answers*;
                 var imageLoader:Loader = new Loader();
                  imageLoader.load(new URLRequest(images*));
                  addChild (imageLoader);
                  imageLoader.x = 50;
                  imageLoader.y = 200;

                 break;
             }
            else
             {
            writer = "ERROR";
           removeChild(imageLoader);

             }
       }

```

outputBox.text = writer;  
}

i wanted the loaded image to be removed if the outputBox.text shows ERROR, but i have tried removeChild and unload(), they don’t work. Any help will be greatly appreciated.
