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.
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.
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!
Copy link to clipboard
Copied
try;
if those work, see if you can work out a presave (eg, "preDocumentSaved", "preDocumentSave", "preSave", "preSaved"
There are several ways to run scripts. The most common ways are explained in this section.
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.
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.
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.
Copy the JSFL file for the tool and any other associated files to the Tools folder (see "Saving JSFL files").
If tool is not visible in toolbar, click three dots (Edit Toolbar…)
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.
MMExecute(Javascript command string);
You can also run a script from the command line.
"Animate.exe" myTestFile.jsfl [-AlwaysRunJSFL]
Use the -AlwaysRunJSFL
option to bypass the dialog box that prompts you to confirm script execution.
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
/Applications/Adobe\ Animate\ 2020/Animate.app/Contents/MacOS/Animate \<path of the jsfl file\>
Copy link to clipboard
Copied
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!