Unloading image in loader on thumb click

Alright. I finally found a tutorial that works for what I am trying to do. The thumbs load on a grid and when I click on the thumb they load in the loader. Now I am having trouble removing them. The tutorial has the remove function on the loaded large image so when you click that it removes itself. I would like so that when you click on the a thumb the current image will unload and the thumb that is clicked on will load but can’t figure out how to get it to do that. I figured I’d just add a CLICK listener for the “removeFull” function to the “callFull” function but I think it cancels itself out.

Here is the code I am using: (the code to load and unload is toward the bottom)



**
var columns:Number = 2;
var my_x:Number = 25;
var my_y:Number = 75;
var my_thumb_width:Number = 65;
var my_thumb_height:Number = 65;
var my_images:XMLList;
var my_total:Number;

var container_mc:MovieClip;

var x_counter:Number = 0;
var y_counter:Number = 0;

var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("xml/gallery.xml"));

myXMLLoader.addEventListener(Event.COMPLETE, processXML);

function processXML (e:Event):void{
    var myXML:XML = new XML(e.target.data);
    
    my_images = myXML.IMAGE;
    my_total = my_images.length();
    
    createContainer();
    callThumbs();
}

function createContainer():void{
    container_mc = new MovieClip();
    container_mc.x = my_x;
    container_mc.y = my_y;
    
    addChild(container_mc);
    ** 
**[COLOR=#FF0000]//The large image loads when the thumb is clicked on.[/COLOR]****
    container_mc.addEventListener(MouseEvent.CLICK, callFull);
    container_mc.buttonMode = true;
}

function callThumbs():void{
    for (var i:Number = 0; i < my_total; i++){
        var thumb_url = my_images*.@THUMB;;
        var thumb_loader = new Loader();
        thumb_loader.load(new URLRequest(thumb_url));
        thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
        
        thumb_loader.name = i;
        
        thumb_loader.x = (my_thumb_width+25)*x_counter;
        thumb_loader.y = (my_thumb_height+25)*y_counter;
        
        if (x_counter+1 < columns){
            x_counter++;
        } else {
            x_counter = 0;
            y_counter++;
        }
    }
}

function thumbLoaded(e:Event):void{
    var my_thumb:Loader = Loader(e.target.loader);
    container_mc.addChild(my_thumb);
}
**
  
 [COLOR=#FF0000]**//This function loads the large image.**[/COLOR]**
function callFull(e:MouseEvent):void{
    var full_loader:Loader = new Loader();
    var full_url = my_images[e.target.name].@FULL;
    full_loader.load(new URLRequest(full_url));
    full_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded);
}
**
  
 [COLOR=#FF0000]**//This function centers the large image in the gallery loader.**[/COLOR]**function fullLoaded(e:Event):void{
    var my_loader:Loader = Loader(e.target.loader);
    MovieClip(parent.parent).gallery.addChild(my_loader);
    my_loader.x = (MovieClip(parent.parent).gallery.width - my_loader.width)/2;
    my_loader.y = (MovieClip(parent.parent).gallery.height - my_loader.height)/2;
    **
 **[COLOR=#FF0000]//The large image unloads when it is clicked on.[/COLOR]****
    my_loader.addEventListener(MouseEvent.CLICK,removeFull);
}
**
  
 [COLOR=#FF0000]**//This function removes the loaded image from the gallery loader.**[/COLOR]**function removeFull(e:MouseEvent):void{
    var my_loader:Loader = Loader (e.currentTarget);
    my_loader.unload();
    removeChild(my_loader);
}**
 


THANKS!
-dan