I'm trying to pass parameters from ActionScript3 to JSFL for an Adobe Animate tool, but I'm not entirely sure it's possible given a couple of suggest solutions I've tried. I currently call functions within a JSFL script via MMExecute and runscript which works well:
MMExecute("fl.runScript(fl.configURI + 'WindowSWF/import.jsfl','Test Function');");
... but I need to pass parameters to a function, not just call a function.
I've been told that ExternalInterface would achieve this as in the function below, but the function I call is never executed ( I don't receive any errors).
function callJSFLScript(param1: String, param2: int): void {
if (ExternalInterface.available) {
try {
var jsflScript: String = 'import.jsfl'; // Path to your JSFL script
// Construct data to pass as an object
var data: Object = {
param1: param1,
param2: param2
};
// Serialize data to JSON string
var jsonString: String = JSON.stringify(data);
// Call JSFL script with JSON string parameter
ExternalInterface.call("eval", "fl.script.callScript('" + jsflScript + "', '" + jsonString + "');");
simpleLog("JSFL script called with parameters: " + param1 + ", " + param2);
} catch (error: SecurityError) {
simpleLog("A SecurityError occurred while calling the JSFL script.");
} catch (error: Error) {
simpleLog("An Error occurred while calling the JSFL script.");
}
} else {
simpleLog("ExternalInterface is not available.");
}
}
Cheers Ant