\n'); } function PassVariableToFlashPlayer(variable, value) { var val = "" + value; // convert value to a string, if it is not that already window.document.MediatorFlash.SetVariable(variable, val); } function MediatorFlash_DoFSCommand(command, args) { // un-escape any newline chars, to avoid problems with the eval() call var i = 0; while ( (i = args.indexOf("\r\n"), i) != -1 ) { args = args.substring(0, i) + "\\n" + args.substring(i + 2); i += 2; } i = 0; while ( (i = args.indexOf("\n"), i) != -1 ) { args = args.substring(0, i) + "\\n" + args.substring(i + 1); i += 2; } var destinationVariable = ""; if ( command == "GetValue" || command == "GetLastError" || command == "GetLastErrorString" || command == "GetDiagnostic") { // Get and remove the destination (Flash Player) variable from the arguments string, and save it // in the destinationVariable. The destinationVariable is seperated from the argument by a comma // that happen to be both preceeded and followed by a single-quotation mark ('). It is save to // assume that this character sequence will can not occur in the arguments to the call, since neather // GetValue argument or the GetDiagnostic argument should contain it. var i = args.indexOf("',"); if (i != -1) { destinationVariable = args.substring(i + 2); args = args.substring(0, i + 1); } else { // no comma found in the args string, so assume that no argument to the SCORM method is needed, // and that args only contains the destination variable. destinationVariable = args; args = ""; } if (g_objAPI != null) { if (command != "GetLastErrorString" ) { var retVal = eval("g_objAPI." + command + "(" + args + ")"); PassVariableToFlashPlayer(destinationVariable, retVal); } else { var retVal = g_objAPI.GetLastError(); retVal = g_objAPI.GetErrorString(retVal); PassVariableToFlashPlayer(destinationVariable, retVal); } } else { alert("g_objAPI." + command + "(" + args + ")" + " call attempted, but SCORM API was not found."); PassVariableToFlashPlayer(destinationVariable, ""); } } else { if (g_objAPI != null) { var retVal = eval("g_objAPI." + command + "(" + args + ")"); } else { alert("g_objAPI." + command + "(" + args + ")" + " call attempted, but SCORM API was not found."); } } }