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

	 */
	public function ExternalMethod(host:Object, methodInfo:Object)
	{
		if (!json)
		{
			// one-time external initialization
			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;",
				"};"
			);
		}
		
		var name:String = methodInfo.name;
		method = host[name];
		// find the number of required parameters
		paramCount = 0;
		while (paramCount < method.length && !methodInfo.parameters[paramCount].optional)

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