 		}
 		
 		public function testRunStarted( description:IDescription ):void{
-			
+			// XML Socket in flexbuilder is expecting a startTestRun node at the begining of the results.
+			// it seems to use this to reset hte current results, and prepopulate the total number of tests
+			// however, in flexunit4, we are unable to determine the total number of tests before hand, so
+			// we are sending through an empty startTestRun node, so the reset can still happen.
+			sendResults("<startTestRun totalTestCount='0'  projectName='' contextName='' />");
 		}
 
 		public function testRunFinished( result:Result ):void {
-			printHeader( result );
-			printResults(result);
+		
+			// if we want to wait until all tests are finished before sending any results, 
+			// in this method we should first call printHeader, then printResults, then printFooter
+			// however, as we are now sending through results as they happen, we use this method only to call printFooter		
+			//printHeader( result );
+			//printResults(result);
 			printFooter( result );
 		}
 
 		public function testStarted( description:IDescription ):void {
-			
+			// called before each test
 		}
 		
 		public function testFinished( description:IDescription ):void {
-			//logger.info( description.displayName + " ." );
-			if(description.displayName != lastFailedTest.displayName){
+			// called after each test
+			if(!lastFailedTest || description.displayName != lastFailedTest.displayName){
 				var desc:Descriptor = getDescriptorFromDescription(description);
+				sendResults("<testCase name='"+desc.method+"' testSuite='"+desc.suite+"'  status='"+SUCCESS+"'/>");
 				msgQueue.push( "<testCase name='"+desc.method+"' testSuite='"+desc.suite+"'  status='"+SUCCESS+"'/>");
 			}
 		}
 
 		public function testAssumptionFailure( failure:Failure ):void {
-			
+			// called on assumptionFail
 		}
 
 		public function testIgnored( description:IDescription ):void {
-			
+			// called on ignored test
 			var desc:Descriptor = getDescriptorFromDescription(description);
+			sendResults("<testCase name='"+desc.method+"' testSuite='"+desc.suite+"'  status='"+IGNORE+"'/>");
 			msgQueue.push("<testCase name='"+desc.method+"' testSuite='"+desc.suite+"'  status='"+IGNORE+"'/>");
-			//logger.info( description.displayName + " I" );
 		}
 	
 	
 		public function testFailure( failure:Failure ):void {
+			// called on a test failure
 			lastFailedTest = failure.description;
 			var descriptor:Descriptor = getDescriptorFromDescription(failure.description);
 			var type : String = failure.description.displayName

				socket.send( msg );
				trace(msg);
			}
			//
		}

		private function handleConnect(event:Event):void{
			_ready = true;
			dispatchEvent( new Event( AsyncListenerWatcher.LISTENER_READY ) );
			//dispatchEvent( event );
			
		}
		private function errorHandler(event:Event):void{
			dispatchEvent( new Event( AsyncListenerWatcher.LISTENER_FAILED ) );
			//dispatchEvent( event ) ;
			//throw new Error("unable to connect to flex builder to send results");
		}
	
		

		 */

		private function getDescriptorFromDescription(description:IDescription ):Descriptor{
			// reads relavent data from descriptor
			var descriptor:Descriptor = new Descriptor();
			var descriptionArray:Array = description.displayName.split("::");
			descriptor.path = descriptionArray[0];
