Copy link to clipboard
Copied
During JSFL encoding, this error window comes up when opening FLA produced with AS2 encoding. is there a way to turn this off with JSFL encoding?
Hi.
Run this before opening the documents:
fl.suppressAlerts = true;
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
Run this before opening the documents:
fl.suppressAlerts = true;
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
thx bro working
Copy link to clipboard
Copied
You're welcome.
Copy link to clipboard
Copied
Dear João,
I'm writing a script automating the import process of files to the library where I already have an item with a same name. The alert
keeps popping up even with the suppression line. The code is below. I read from Flash Scripting Reference that the third paremeter, showDialog is:
A Boolean value that specifies whether to display the Import dialog box. Specifying true displays the import dialog. If you specify false, the function imports the file using specifications set in the Preferences dialog. The default is true.
I haven't been able to find that Preference, since the Sync Settings tab is missing in my Animate. Any suggestions?
Many thanks in advance!
Funtom
fl.suppressAlerts = true;
var doc = fl.getDocumentDOM();
var fileURL = "file:///Macintosh%20HD/Users/(usr)/Documents/_test/images/bnr_980x400.png";
doc.importFile(fileURL, true, false, false);
Copy link to clipboard
Copied
If I understand you correctly, then try inserting all the library elements into a folder with a random name. Then there will be no name conflict and the pop-up window will not appear
Copy link to clipboard
Copied
Thanks for the idea. In my process the idea is to update old library items with new ones. The Animate document acts as a template and each library item has a certain animation connected to it. I'm running the jsfl as part of an applescript folder action in mac. I wrote a (n ugly) workaround for now.
tell application "Finder" to set fl_scriptPath to ("MacHD:Users:" & usr & ":Documents:animExp.jsfl" as string)
with timeout of 1 second
try
tell application "Adobe Animate 2023"
activate
open alias fl_scriptPath
end tell
on error eMes number eNum
tell application "System Events"
tell application process "Adobe Animate 2023"
keystroke tab
keystroke tab
keystroke space
keystroke return
end tell
end tell
end try
end timeout
Copy link to clipboard
Copied
Hi.
Sorry for the late reply.
The only solution I could think of is:
- To check if the an item with the same name exists in the root of the Library;
- If so, move this item to a temp folder;
- Then import the new image;
- Move the new image to the temp folder because in this way we can overpass the replace prompt;
- Move the image back to the root;
- Delete the temp folder.
And there's no need to suppress the alerts.
Import to the Library Without Prompt JSFL:
var imageName = "pexels-darina-belonogova-9160592.jpg";
var tempFolderNamePrefix = "temp_";
var dom, lib, imageExists;
var imageURL; // in this example, the image is in the same folder where this script is located
function main()
{
dom = fl.getDocumentDOM();
if (!dom)
{
alert("Please open up a FLA first.");
return;
}
imageURL = fl.scriptURI.replace(fl.scriptURI.split("/").pop(), "") + imageName;
if (!fl.fileExists(imageURL))
{
alert("The image URL is wrong or the image doesn't exist.");
return;
}
lib = dom.library;
imageExists = lib.itemExists(imageName)
if (imageExists)
{
var tempFolderName = tempFolderNamePrefix + Date.now();
lib.newFolder(tempFolderName);
lib.moveToFolder(tempFolderName, imageName, true);
}
dom.importFile(imageURL, true, false, false);
if (imageExists)
{
lib.moveToFolder(tempFolderName, imageName, true);
lib.moveToFolder("", tempFolderName + "/" + imageName, true);
lib.deleteItem(tempFolderName);
}
}
main();
Source / file / JSFL / download:
https://bit.ly/3T396fm
Usage (one of the following):
- Double click the script file;
- Or drag and drop the script file over the Animate IDE;
- Or place it in the Commands folder to run it.
To run the code from the commands folder, place it in one of the following paths:
macOS:
/Users/<USER>/Library/Application Support/Adobe/<ANIMATE_VERSION>/<LANGUAGE>/Configuration/Commands
E.g.:
/Users/johndoe/Library/Application Support/Adobe/Animate 2023/en_US/Configuration/Commands
Windows:
<BOOT_DEVICE>\Users\<USER>\AppData\Local\Adobe\Animate <ANIMATE_VERSION>\<LANGUAGE>\Configuration\Commands
E.g.:
C:\Users\johndoe\AppData\Local\Adobe\Animate 2021\en_US\Configuration\Commands
Then you can run the command in Animate by going to Commands > Your Command Name.
I hope it helps and please let me know if there's something to fix or improve.
Regards,
JC
Copy link to clipboard
Copied
João,
Many thanks! I'll try to implement your solution and get back to you if necessary. And your reply time was really good! 🙂
Cheers!
Funtom
Copy link to clipboard
Copied
Fantastic! You're welcome!
Copy link to clipboard
Copied
Works like a charm!
Copy link to clipboard
Copied
Awesome! I'm really glad it was helpful to you. Have a nice day!