 				}
 				_timer.start();
 				_isPaused = false;
-				_isLoaded = true;	
-				sendEvent(HtmlMediaEvent.PLAYING);						
+				sendEvent(HtmlMediaEvent.PLAY);
+				sendEvent(HtmlMediaEvent.PLAYING);
+				_hasStartedPlaying = true;
 			}
 
 		}			
-		
+
 		public function pause():void {
+			if (_stream == null)
+				return;
+				
 			_stream.pause();
 			_isPaused = true;
 			_timer.stop();			
-			
+
 			_isPaused = true;
-			sendEvent(HtmlMediaEvent.PAUSED);
+			sendEvent(HtmlMediaEvent.PAUSE);
 		}		
-		
+
 		public function setCurrentTime(pos:Number):void {
+			if (_stream == null)
+				return;
+				
 			_stream.seek(pos);
 			sendEvent(HtmlMediaEvent.SEEKED);
 		}
-				
+
 		public function setVolume(volume:Number):void {
+			if (_stream == null)
+				return;
+			
 			_soundTransform = new SoundTransform(volume);
 			_stream.soundTransform = _soundTransform;
 			_volume = volume;
-			
+
 			_isMuted = (_volume == 0);
-			
+
 			sendEvent(HtmlMediaEvent.VOLUMECHANGE);
 		}
 
-		
+
 		public function setMuted(muted:Boolean):void {			
-			
+
 			if (_isMuted == muted)
 				return;
-	
+
 			if (muted) {
 				_oldVolume = _stream.soundTransform.volume;
 				setVolume(0);
 			} else {
 				setVolume(_oldVolume);
 			}
-			
+
 			_isMuted = muted;
 		}
 
-		
+
 		private function sendEvent(eventName:String) {
-			
+
 			// calculate this to mimic HTML5
 			_bufferedTime = _bytesLoaded / _bytesTotal + _duration;			
-			
+
 			// build JSON
 			var values:String = 
 							"{duration:" + _duration + 

							",videoWidth:" + _videoWidth +
							",videoHeight:" + _videoHeight +							
							"}";
			
			_element.sendEvent(eventName, values);			
		}		
	}
}
		

﻿package htmlelements
{
	import flash.display.Sprite;
	import flash.events.*;
