/// <summary> /// Called when Flash Player raises the FlashCallEvent (when an External Interface call /// is made by ActionScript) /// </summary> /// <param name="sender">The object raising the event</param> /// <param name="e">The arguments for the event</param> private void _flashControl_FlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e) { ExternalInterfaceCall functionCall = ExternalInterfaceSerializer.DecodeInvoke(e.request); ExternalInterfaceCallEventArgs eventArgs = new ExternalInterfaceCallEventArgs(functionCall); object response = OnExternalInterfaceCall(eventArgs); _flashControl.SetReturnValue(ExternalInterfaceSerializer.EncodeResult(response)); }
/// <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="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; } }