/// <summary> /// Flashの関数を実行する /// </summary> /// <param name="methodName">メソッド名</param> /// <param name="param">引数</param> private void CallFlashMethod(string methodName, string param) { if (flash.FrameLoaded(0)) { flash.CallFunction("<invoke name=\"" + methodName + "\" returntype=\"xml\"><arguments><string>" + param + "</string></arguments></invoke>"); } }
/// <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) { return("null string"); } }
/// <summary> /// Flashの関数を実行する /// </summary> /// <param name="methodName">メソッド名</param> /// <param name="param">引数</param> private void CallFlashMethod(string methodName, string param) { if (flash.FrameLoaded(0)) { var request = new XElement("invoke", new XAttribute("name", methodName), new XAttribute("returntype", "xml"), new XElement("arguments", new XElement("string", param) ) ); try { flash.CallFunction(request.ToString(SaveOptions.DisableFormatting)); } catch (COMException) { } } }
public static void call(AxShockwaveFlash obj, String funcName, String[] ary) { //"<invoke name=\"setPath\" returntype=\"void\"><arguments><string>test</string></arguments></invoke>" String str = "<invoke name=\"" + funcName + "\" returntype=\"void\">"; if (ary.Length > 0) { str += "<arguments>"; for (int i = 0; i < ary.Length; i++) { str += "<string>" + ary[i] + "</string>"; } str += "</arguments>"; } str += "</invoke>"; obj.CallFunction(str); }
/// <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; } }