         private var _idleTime:int;
         private var _isMouseActive:Boolean
 		private var _isOverStage:Boolean = false;
+		
+		// security checkes
+		private var securityIssue:Boolean = false; // When SWF parameters contain illegal characters
+		private var directAccess:Boolean = false; // When SWF visited directly with no parameters (or when security issue detected)		
 
 
 		public function FlashMediaElement() {
 
 			// show allow this player to be called from a different domain than the HTML page hosting the player
 			Security.allowDomain("*");
-
+			
+			// check for security issues (borrowed from jPLayer)
+			checkFlashVars(loaderInfo.parameters);
+			
+			
+			// add debug output
+			_output = new TextField();
+			_output.textColor = 0xeeeeee;
+			_output.width = stage.stageWidth - 100;
+			_output.height = stage.stageHeight;
+			_output.multiline = true;
+			_output.wordWrap = true;
+			_output.border = false;
+			_output.filters = [new DropShadowFilter(1, 0x000000, 45, 1, 2, 2, 1)];
+
+			_output.text = "Initializing...\n";
+			addChild(_output);
+			_output.visible = securityIssue;			
+
+			if (securityIssue) {
+				_output.text = "WARNING: Security issue detected. Player stopped.";
+				return;
+			}
+				
 			// get parameters
 			var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
-			_mediaUrl = (params['file'] != undefined) ? String(params['file']).replace("\\\"","") : ""; // replacing quotes is for XSS
+			_mediaUrl = (params['file'] != undefined) ? String(params['file']) : "";
 			_autoplay = (params['autoplay'] != undefined) ? (String(params['autoplay']) == "true") : false;
 			_debug = (params['debug'] != undefined) ? (String(params['debug']) == "true") : false;
 			_isVideo = (params['isvideo'] != undefined) ? ((String(params['isvideo']) == "false") ? false : true  ) : true;

			//_alwaysShowControls = true;

			//_debug=true;
			
			// debugging
			_output = new TextField();
			_output.textColor = 0xeeeeee;
			_output.width = stage.stageWidth - 100;
			_output.height = stage.stageHeight;
			_output.multiline = true;
			_output.wordWrap = true;
			_output.border = false;
			_output.filters = [new DropShadowFilter(1, 0x000000, 45, 1, 2, 2, 1)];

			_output.text = "Initializing...\n";
			addChild(_output);
			_output.visible = _debug;
			

			// position and hide

			
		}
				
		// borrowed from jPLayer 
		// https://github.com/happyworm/jPlayer/blob/e8ca190f7f972a6a421cb95f09e138720e40ed6d/actionscript/Jplayer.as#L228
		private function checkFlashVars(p:Object):void {
			var i:Number = 0;
			for each (var s:String in p) {
				if (isIllegalChar(s)) {
					securityIssue = true; // Illegal char found
				}
				i++;
			}
			if(i === 0 || securityIssue) {
				directAccess = true;
			}
		}
		
		private function isIllegalChar(s:String):Boolean {
			var illegals:String = "' \" ( ) { } * + / \\ < > = document";
			if(Boolean(s)) { // Otherwise exception if parameter null.
				for each (var illegal:String in illegals.split(' ')) {
					if(s.indexOf(illegal) >= 0) {
						return true; // Illegal char found
					}
				}
			}
			return false;
		}				
				
				
		// START: Controls and events
		function mouseActivityMove(event:MouseEvent):void {
			
