/// <summary> /// Calls the ActionScript function which is registered as a callback method with the /// ActionScript ExternalInterface class. /// </summary> /// <param name="functionName">The function name registered with the ExternalInterface class /// corresponding to the ActionScript function that is to be called</param> /// <param name="args">Additional arguments, if any, to pass to the ActionScript function.</param> /// <returns>The result returned by the ActionScript function, or null if no result is returned.</returns> /// <exception cref="System.Runtime.Interop.COMException">Thrown when there is an error /// calling the method on Flash Player. For instance, this exception is raised if the /// specified function name is not registered as a callable function with the ExternalInterface /// class; it is also raised if the ActionScript method throws an Error.</exception> public object Call(string functionName, params object[] arguments) { try { string request = ExternalInterfaceSerializer.EncodeInvoke(functionName, arguments); string response = _flashControl.CallFunction(request); object result = ExternalInterfaceSerializer.DecodeResult(response); return(result); } catch (COMException) { throw; } }
/// <summary> /// Calls the ActionScript function which is registered as a callback method with the /// ActionScript ExternalInterface class. /// </summary> /// <param name="functionName">The function name registered with the ExternalInterface class /// corresponding to the ActionScript function that is to be called</param> /// <param name="args">Additional arguments, if any, to pass to the ActionScript function.</param> /// <returns>The result returned by the ActionScript function, or null if no result is returned.</returns> /// <exception cref="System.Runtime.Interop.COMException">Thrown when there is an error /// calling the method on Flash Player. For instance, this exception is raised if the /// specified function name is not registered as a callable function with the ExternalInterface /// class; it is also raised if the ActionScript method throws an Error.</exception> public Object Call(String functionName, params Object[] arguments) { try { Trace.WriteLine("ExternalInterfaceProxy.Call:EncodeInvoke\n"); string request = ExternalInterfaceSerializer.EncodeInvoke(functionName, arguments); Trace.WriteLine("ExternalInterfaceProxy.Call:CallFunction-" + request + "\n"); string response = _flashControl.CallFunction(request); Trace.WriteLine("ExternalInterfaceProxy.Call:DecodeResult\n"); object result = ExternalInterfaceSerializer.DecodeResult(response); return(result); } catch (COMException) { Trace.WriteLine("ExternalInterfaceProxy.Call:COMException\n"); throw; } }