Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JSFL commands: Importing hundreds of elements takes a long time and freezes the application.

Community Beginner ,
Jul 01, 2025 Jul 01, 2025

When I try to import elements using a script I wrote, it takes a very long time. The first few elements take less than a second, but once the count reaches around 100 (I don't have an exact number), the import time increases to 2–5 seconds per element.

The problem is that Adobe Animate takes 5–10 minutes to run the script. If I delete this line, the script only takes about 5 seconds. Importing 10 elements takes just 10 seconds.

However, when importing hundreds of elements (e.g., 200), the import time increases with each element, and Adobe Animate becomes increasingly slow. At some point, if you click anywhere in Animate, the application crashes (on Windows 11 Pro).

I've tried several workarounds: importing in batches of 10 or 20 elements, cleaning the memory after each batch... but when the number of symbols is large, the app still crashes and stops responding.

The problem seems to be with this line:

 

lib.addItemToDocument({ x: 0.0 + x * elementIndex, y: y }, libPath);

 

I’ve also tried setting the layer, creating new layers, etc., but nothing seems to work.

Documentation:

https://web.archive.org/web/20121223105042/http://photoshop-flash-coreldraw-seo-help.com/adobe-flash...

 

https://help.adobe.com/en_US/flash/cs/extend/index.html

 

 

Can you help me?

 

430
Translate
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 Expert ,
Jul 02, 2025 Jul 02, 2025

what if you import in batches of 100?

Translate
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 02, 2025 Jul 02, 2025

I've done with several batches, by 100 by 10, but when the number of the symbols are increased the script go slow.

I don't know how to clean the memory between batches. I've tried document.selectnone(), but nothing works. I couldn't find any command to clean the memory to increase the speed.

I've code in functions to test if this clean the memory in each call of every function. 

 

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025

add a timer to delay your batches.

Translate
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 03, 2025 Jul 03, 2025

I've alredy tested with delay.

function debugPause(ms) {
    if (!ENABLE_PAUSE) return;
    ms = ms || 10;
    var start = new Date().getTime();
    while (new Date().getTime() < start + ms) {}
  }

 Every 50 elements I wait some time... I think the cause of take a lot of time is the mumber of the elements. 

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025

Hi.

 

I would recommend you to consider using an AS3 extension as you'll possibly have more performance and more time management options (e.g.: Timer, ENTER_FRAME, setInterval, setTimeout).

You'll at least be able to keep Animate usable and you'll also be able to create some loading message for your users.

 

Regards,

JC

Translate
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 03, 2025 Jul 03, 2025

I never use AS3 files for commands. Do you recomend me any documentation to see the possibilities of import symbols, etc..?
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/

 

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025

if you batch load 100 elements how long does it take?  (t1)

 

if batch load 200 elements how long does it take?

 

if you load 100, wait t1 and then load 100, how long does it take?

Translate
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 03, 2025 Jul 03, 2025

for 243 elements take 453s

for the first 100 takes 20s... after takes 2-5 seconds every symbol

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025

if you load 100, delay 25 seconds and then load 100 how long does that take?

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025

[Replied below]

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025

This tutorial is a very nice introduction:
https://ajarproductions.com/blog/2011/02/08/creating-flash-extensions-pt1/

As an example, a simple for loop like this took around 17 seconds to complete, but it blocks Animate.

for (var i:uint = 0; i < 1000; i++)
	MMExecute("fl.getDocumentDOM().library.addItemToDocument({ x: 0, y: 0 }, 'Rec');");

 

In this other example, Animate doesn't get blocked but it takes around 78 seconds to complete, which makes the need for visual feedback even more important.

import flash.events.Event;
import flash.utils.getTimer;

var count:uint = 0;
var total:uint = 1000;

function enterFrameHandler(e:Event):void
{
	count++;
	
	if (count < total)
		MMExecute("fl.getDocumentDOM().library.addItemToDocument({ x: 0, y: 0 }, 'Rec');");
	else
	{
		MMExecute("fl.trace('total time (MS): " + getTimer() + "');");
		stage.removeEventListener(e.type, arguments.callee);
	}
}

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

 

But these are only quick tests that I run. You can explore other options as AS3 and the Flash API are very robust.

 

Regards,

JC

Translate
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 03, 2025 Jul 03, 2025

I've just create a impor.as3 file and I placed in C:\Users\USER\AppData\Local\Adobe\Animate 2024\en_US\Configuration\Commands\Import Profile.as
 C:\Users\USER\AppData\Local\Adobe\Animate 2024\en_US\Configuration\Commands\Import Profile.as3
and the ADobe aNimate doesn't reconize the command to execute.

 

 

Translate
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 Expert ,
Jul 03, 2025 Jul 03, 2025
LATEST

You actually need to create a SWF file and add it to the WindowSWF folder:
https://helpx.adobe.com/animate/kb/install-animate-extensions.html

 

If you can't find it, run this JSFL command:

fl.trace(FLfile.uriToPlatformPath(fl.configURI));
Translate
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