Execute JSFL when user saves file?

Community Beginner ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

Are there anyway to add callbacks for file saving in animate JSFL?

Id like to do a few checks to ensure that the user is not saving a file while they are using substituted fonts. 

Views

116

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

yes.

 

jsfl has event listeners for the fl object.that can detect "documentNew", "documentOpened", "documentClosed", "mouseMove", "documentChanged", "layerChanged""timelineChanged", "frameChanged", "prePublish", "postPublish", "selectionChanged", and dpiChanged.

 

and the file object can delete files, if that's what you want.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 14, 2021 Feb 14, 2021

Copy link to clipboard

Copied

This is getting there, but I dont see any listeners for a pre-save.

Is there any way to access such an event?

Also how does one run a script on startup to execute the fl.addEventListener() functions?

 

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

try;

 

  1. fl.addEventListener('documentSaved', documentSavedF);
  2. fl.addEventListener('postPublish', postPublishF);

 

if those work, see if you can work out a presave (eg, "preDocumentSaved", "preDocumentSave", "preSave", "preSaved"

 

 

Re Running scripts

There are several ways to run scripts. The most common ways are explained in this section.

TO RUN A SCRIPT THAT YOU ARE CURRENTLY VIEWING OR EDITING:

  • Right-click (Command-click on the Macintosh) and choose Run Script.

  • Click the Run Script icon on the Script window toolbar.

This option lets you run a script before you have saved it. This option also lets you run a script even if no FLA files are open.

TO RUN A SCRIPT THAT IS IN THE COMMANDS FOLDER, DO ONE OF THE FOLLOWING:

  • From the authoring environment, select Commands > Script Name.

  • Use a keyboard shortcut that you have assigned to the script. To assign a keyboard shortcut, use Edit > Keyboard Shortcuts and select Drawing Menu Commands from the Commands pop-up menu. Expand the Commands node in the menu tree to view a list of available scripts.

TO RUN A COMMAND SCRIPT THAT IS NOT IN THE COMMANDS FOLDER, DO ONE OF THE FOLLOWING:

  • From the authoring environment, select Commands > Run Command, and then select the script to run.

  • From within a script, use the fl.runScript() command.

  • From the file system, double-click the script file.

TO ADD A TOOL IMPLEMENTED IN A JSFL FILE TO THE TOOLS PANEL:

  1. Copy the JSFL file for the tool and any other associated files to the Tools folder (see "Saving JSFL files").

  2. If tool is not visible in toolbar, click three dots (Edit Toolbar…)

  3. Add the tool to the list of available tools.

You can add individual JavaScript API commands to ActionScript files by using the MMExecute() function, which is documented in the ActionScript 3.0 Language and Components Reference. However, the MMExecute() function has an effect only when it is used in the context of a custom user interface element, such as a component Property inspector, or a SWF panel within the authoring environment. Even if called from ActionScript, JavaScript API commands have no effect in Flash Player or outside the authoring environment.

TO ISSUE A COMMAND FROM AN ACTIONSCRIPT SCRIPT:

  • Use the following syntax (you can concatenate several commands into one string):
MMExecute(Javascript command string);

You can also run a script from the command line.

TO RUN A SCRIPT FROM THE COMMAND LINE ON WINDOWS:

  • Use the following syntax (add path information as required):
"Animate.exe" myTestFile.jsfl [-AlwaysRunJSFL]

Use the -AlwaysRunJSFL option to bypass the dialog box that prompts you to confirm script execution.

TO RUN A SCRIPT FROM THE "TERMINAL" APPLICATION ON THE MACINTOSH, USE EITHER OF THE FOLLOWING:

  • Use the following osacript syntax (add path information as required):
osascript -e 'tell application "Animate" to open alias "Mac OS X:Users:user:myTestFile.jsfl" '

The osascript command can also run AppleScript in a file. For example, you could include the following text in a file named myScript:

tell application "Animate"
open alias "Mac OS X:Users:user:myTestFile.jsfl" 
end tell

Then, to run the script, you would use this command:
osascript myScript

  • Use the Animate command:
/Applications/Adobe\ Animate\ 2020/Animate.app/Contents/MacOS/Animate \<path of the jsfl file\>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

LATEST

In theory, the following should be usable (haven't tried all these myself):

 

debugExecutionChanged
deleteSyncSettingsSuccess
documentChanged
documentClosed
documentContentChanged
documentNew
documentOpened
documentRedo
documentSaved
documentUndo
dpiChanged
frameChanged
layerChanged
libraryChanged
postPublish
prePublish
selectionChanged
syncApplyPending
syncError
syncIdle
themeChanged
timelineChanged

 

Enjoy!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines