0

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

3
  • JSFL — script to automate Flash Authoring design process. You can call it from your app only if you run the app from Flash IDE. ExternalInterface is a class that allows your app to communicate with the environment, like HTML page or host app. If you run your app in Flash IDE, there is no environment to communicate with. Commented Jun 24, 2024 at 16:55
  • So would I be right in thinking that there is no way to pass parameters from ActionScript3 to JSFL (Adobe Animate)? I've investigated several methods, including generated a temp cache file by exporting a json script (using FileReference) but this presents a dialgoue box. Equally, I tried sharedobjects but I can't read these in from jfsl. Any other suggestions much appreciated! Commented Jun 27, 2024 at 14:24
  • This ajarproductions.com/blog/2011/02/08/… guide actually claims that you can pass parameters and call as many JSFL methods as you want per a single call: MMExecute("alert('hello');"); Commented Jun 27, 2024 at 16:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.