Hi,

I'm working with lastfm's api to find similar artists. I have the search function running which will load the similar artists however I am having trouble removing the existing results when the search is updated.

I know it is something really simple.. but maybe i'm going the wrong way about it..you can see where i've put a reCheckLastFm function.

Any help on this is greatly appreciated. Thanks.

Code:
package {
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class Main extends MovieClip {
		
		private var searchField : Search;
		private var similarArtists : SimilarArtists;
		private var searched : String;
		private var searchBtn : Search_Btn;


		//private var search
		public function Main() {
			this.searchField = new Search();
			this.searchField.x = (this.stage.stageWidth/2) - (this.searchField.width/2);
			this.searchField.y = 10;
			this.stage.addChild(this.searchField);
			this.checkChildren();
			
			this.similarArtists = new SimilarArtists();
		}
		
		/*********************************** SEARCH STUFF ***********************************/
		
		private function searchListener(event:MouseEvent):void
			{
				if(this.stage.contains(this.similarArtists)) {
				   trace("REMOVE SIMILAR ARTISTS");
				   reCheckLastFm();
				   //this.stage.removeChild(this.similarArtists);
				}
				
				if(this.searchField.search_txt.text != "")
				{
					searched = this.searchField.search_txt.text;
					trace(this.searchField.search_txt.text);
					
					var myTextField:TextField = new TextField();
			
					var searchText:String = searched;
					
					myTextField.width = 300;
					myTextField.height = 100;
					myTextField.x = 500;
					myTextField.y = 350;
					myTextField.background = true;
					myTextField.backgroundColor = 0xFFFF00;
					myTextField.border = true;
					myTextField.borderColor = 0xFF0000;
					
					addChild(myTextField);
					
					myTextField.text = "You searched for: " + searchText;
				}
				this.checkLastFm();
			}
			
			private function checkChildren() : void {
				
				for(var i:int = 0; i<this.searchField.numChildren; i++) {
					trace("i is"+i);
					var tmp = this.searchField.getChildAt(i);
					
					if(tmp is Search_Btn) {
						this.searchBtn = tmp;
					}
				}
				this.searchBtn.addEventListener(MouseEvent.CLICK, searchListener); 
			}
			
			//Add similar artists
			
			private function checkLastFm () : void {
				this.similarArtists.startSearch(this.searched);
				this.stage.addChild(this.similarArtists);
			}
			
			//NEW SEARCH : reload similar artists
			
			private function reCheckLastFm () : void {
				this.stage.removeChild(this.similarArtists);
				this.similarArtists.startSearch(this.searched);
				this.stage.addChild(this.similarArtists);
			}
	


	}
	
}