Image Gallery Help

Hi there everybody,

I am currently in the process of making an image gallery at university over the period of the semester. Eventually it will be able to search through flikr and pull thumbnails from there but for now we are just getting the fundamentals working. Last weeks task was to have the int amount of thumbnails show up depending on the number u placed in the search field. So in other words i type in 3 in the search field, and 3 placeholder images show up. The problem is having to remove them from the stage and the array so that when u type in 2 or 1 after having typed 3, that it erases the last search results from the array and the stage. This is my code below which half works. It will place however many images you tell it to, but will not erase them next time u press search. ANY HELP WOULD BE GREATLY APPRECIATED!

public function searchClicked(e:MouseEvent):void
var searchNumber:int = int(search_txt.text);
var startX:int = 150;
var startY:int = 270;
var space:int = 300;
var thumbnails:Array = new Array();

			for (var a = 0; a < thumbnails.length; a++)
			for (var i = 0; i < searchNumber; i++) 
				var thumbnail:Thumbnail = new Thumbnail();
				thumbnails* = thumbnail;
				thumbnail.scaleX = .5;
				thumbnail.scaleY = .5;
				thumbnail.x = startX;
				thumbnail.y = startY;
				startX = startX + 100;