 				"JSON_CALL": JSON_CALL,
 				"JSON_REPLACER": JSON_REPLACER,
 				"JSON_REVIVER": JSON_REVIVER,
-				"methodName": name,
+				"methodName": methodName,
 				"paramCount": paramCount
 			},
 			"weave[methodName] = function(){",

			"}"
		);
		
		registeredMethods[name] = this;
	}
	
	public var method:Function;

	 */
	public function ExternalMethod(host:Object, methodInfo:Object)
	{
		if (!initialized)
		{
			// one-time initialization attempt
			initialized = true;
			try
			{
				json = getDefinitionByName("JSON");
				ExternalInterface.addCallback(JSON_CALL, handleJsonCall);
				WeaveAPI.executeJavaScript(
					{
						"JSON_REPLACER": JSON_REPLACER,
						"JSON_REVIVER": JSON_REVIVER,
						"NOT_A_NUMBER": NOT_A_NUMBER,
						"UNDEFINED": UNDEFINED,
						"INFINITY": INFINITY,
						"NEGATIVE_INFINITY": NEGATIVE_INFINITY
					},
					"weave[JSON_REPLACER] = function(key, value){",
					"    if (value === undefined)",
					"        return UNDEFINED;",
					"    if (typeof value != 'number' || isFinite(value))",
					"        return value;",
					"    if (value == Infinity)",
					"        return INFINITY;",
					"    if (value == -Infinity)",
					"        return NEGATIVE_INFINITY;",
					"    return NOT_A_NUMBER;",
					"};",
					"weave[JSON_REVIVER] = function(key, value){",
					"    if (value === NOT_A_NUMBER)",
					"        return NaN;",
					"    if (value === UNDEFINED)",
					"        return undefined;",
					"    if (value === INFINITY)",
					"        return Infinity;",
					"    if (value === NEGATIVE_INFINITY)",
					"        return -Infinity;",
					"    return value;",
					"};"
				);
			}
			catch (e:Error)
			{
				trace(e.getStackTrace() || "Your version of Flash Player does not have native JSON support.");
			}
		}
		
		// backwards compatibility
		if (!json)
		{
			ExternalInterface.addCallback(methodInfo.name, host[methodInfo.name]);
			return;
		}
		
		var methodName:String = methodInfo.name;
		method = host[methodName];
		// find the number of required parameters
		paramCount = 0;
		while (paramCount < method.length && !methodInfo.parameters[paramCount].optional)
