Open ultra0000 opened 5 days ago
Relevant code from ExternalInterfaceHandler
:
public static function addCallback(externalMethod:String, callback:Function) : void
{
try
{
if(!externalMethods[externalMethod])
{
externalMethods[externalMethod] = new ExternalInterfaceMethod(externalMethod);
}
(externalMethods[externalMethod] as ExternalInterfaceMethod).addCallback(callback);
}
catch(e:Error)
{
}
}
public static function removeCallback(externalMethod:String, callback:Function) : void
{
var method:ExternalInterfaceMethod = externalMethods[externalMethod] as ExternalInterfaceMethod;
if(method)
{
method.removeCallback(callback);
if(method.callbackCount == 0)
{
method.dispose();
delete externalMethods[externalMethod];
}
}
}
public static function performCall(call:String, ... params) : *
{
var logStr:String = "ExternalInterface call: " + call + "(" + params.join(", ") + ");";
if(logStr.length > 300)
{
logStr = logStr.substr(0,300) + "[...]";
}
Log.log(logStr);
if(ExternalInterface.available && EXTERNAL_INTERFACES_ENABLED)
{
try
{
params.unshift(call);
return ExternalInterface.call.apply(null,params);
}
catch(e:Error)
{
Log.log("ExternalInterface call failed!\nCall was:" + call + "\nError data:" + e.toString());
}
}
...
}
ExternalInterfaceMethod
:
package com.rovio.externalInterface
{
import com.rovio.factory.Log;
import flash.external.ExternalInterface;
public class ExternalInterfaceMethod
{
public var externalMethodName:String = "";
private var callbacks:Array = null;
public function ExternalInterfaceMethod(methodName:String)
{
super();
this.externalMethodName = methodName;
if(ExternalInterface.available)
{
ExternalInterface.addCallback(this.externalMethodName,this.methodListener);
}
}
public function methodListener(... args) : *
{
var logStr:* = null;
var i:Number = NaN;
var f:Function = null;
logStr = "call through externalInterface! " + this.externalMethodName + "(";
for(i = 0; i < args.length; i++)
{
logStr += args[i] + ",";
}
logStr += ")";
Log.log(logStr);
var returnValue:* = null;
if(this.callbacks != null)
{
for each(f in this.callbacks)
{
returnValue = f.apply(null,args);
}
}
return returnValue;
}
public function addCallback(callback:Function) : void
{
if(this.callbacks == null)
{
this.callbacks = new Array();
}
if(this.callbacks.indexOf(callback) == -1)
{
this.callbacks.push(callback);
}
}
public function removeCallback(callback:Function) : void
{
if(this.callbacks && this.callbacks.indexOf(callback) != -1)
{
this.callbacks.splice(this.callbacks.indexOf(callback),1);
}
}
public function get callbackCount() : int
{
if(!this.callbacks)
{
return 0;
}
return this.callbacks.length;
}
public function dispose() : void
{
if (ExternalInterface.available)
{
ExternalInterface.addCallback(this.externalMethodName,null);
}
}
}
}
According to ExternalInterface.addCallback docs, using null closure argument on an existing callback should remove it (I haven't tested this, so it might be wrong). We currently throw on null or undefined https://github.com/ruffle-rs/ruffle/blob/fd5ca6ae392b44a3bdf63bfd8407e4c05d17c8dd/core/src/avm2/globals/flash/external/external_interface.rs#L57
According to ExternalInterface.addCallback docs, using null closure argument on an existing callback should remove it (I haven't tested this, so it might be wrong). We currently throw on null or undefined
This game works on Flash and AIR, so the docs must be wrong.
Describe the bug
The authentication data fails to get sent through ExternalInterface, with the following error:
Expected behavior
The game should receive the data properly after authenticating with Discord.
Content Location
https://refresh.teamflashcord.com/
Affected platform
Browser's extension
Operating system
Windows 11
Browser
Microsoft Edge 126.0.2592.81
Additional information
Relevant JavaScript code:
Relevant ActionScript 3 code:
(AIRBird is our Adobe AIR launcher, which uses a different way of authenticating)