 						if (key == 'this')
 						{
 							// put a variable declaration at the beginning of the code
-							var thisVar:String = String(value);
+							var thisVar:String = value as String;
 							if (thisVar)
-								code.unshift(JS_var_this(thisVar));
+							{
+								if (!_objectID)
+									getExternalObjectID(thisVar);
+								code.unshift("var " + thisVar + " = this;");
+							}
 						}
 						else if (key == 'catch')
 						{

			if (!_objectID)
				_objectID = getExternalObjectID();
			return 'document.getElementById("' + _objectID + '")';
		}
		
		/**
		 * Generates a line of JavaScript which intializes a variable equal to this Flash object using document.getElementById().
		 * @param variableName The variable name, which must be a valid JavaScript identifier.
		 */
		private static function JS_var_this(variableName:String):String
		{
			if (!_objectID)
				_objectID = getExternalObjectID(variableName);
			return 'var ' + variableName + ' = ' + JS_this + ';';
		}
		
		/**

					"    }",
					"    if (value === undefined || (typeof value === 'number' && !isFinite(value)))",
					"        return value + JSON_SUFFIX;",
					"    return Array.isArray(value) && !(value instanceof Array) ? [].concat(value) : value;",
					"};",
					
					"flash[JSON_REVIVER] = function(key, value) {",
