Skip to main content
Inspiring
October 31, 2018
Answered

Automating tasks with the Commands menu

  • October 31, 2018
  • 2 replies
  • 1084 views

I wanted to automate a task, but AA doesn't read my intentions

I have a lot of MCs, each one has an image inside, but at different x and y  positions. In one MC pic is on x=200 y=400, other MC has pic on x=500 y=100, etc.

I want to move every image in every MC to x=0 and y=0. I wanted to do it by automating task with history panel. But when I apply the task to other movieclips the images are just moved by the number of pixels the original MC needed them to move. So if the original MC (on which the task is based) had pic on x=100 y=100 I had to set x=0 and y=0. Then I created a task based on this commands. This task applied to other MCs just move them 100 px up and left but doesn't put them at x=0 and y=0.

So if anyone know how to repeat task of setting x=0 and y=0 to all movieclips please let me know.

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

It's because the steps recorded can only take into account one instance. There's no instruction to get another instance and execute the same steps to it.

You need to go one step further and customize the command directly in a JSFL file.

Here is a suggestion.

JSFL script download:

animate_cc_jsfl_align_children_to_the_top_left.zip - Google Drive

Please save the JSFL file in the default commands folder because if you try to run the script from another folder Animate CC may crash.

Commands folder (Windows 10):

<DRIVE>:\Users\<USER>\AppData\Local\Adobe\<FLASH OR ANIMATE NAME AND VERSION>\<LANGUAGE>\Configuration\Commands

Example:

C:\Users\Admin\AppData\Local\Adobe\Animate CC 2019\en_US\Configuration\Commands

Mac OS® X:

Macintosh HD/Users/<username>/Library/Application Support/Adobe/Flash CS5/<language>/Configuration/Commands

I'm not a mac user. I took the location from here.

JSFL code (for reference only):

function main()

{

    var doc = an.getDocumentDOM();

    var selection;

    if (!doc)

    {

          alert("Please open a FLA first.");

          return;

    }

    selection = doc.selection;

    if (selection.length == 0)

    {

          alert("Please select at least one symbol instance first.");

          return;

    }

    doc.selectNone();

    for (var i = selection.length - 1; i >= 0; i--)

    {

          var instance = selection;

          if (instance.instanceType != "symbol")

              continue;

          instance.selected = true;

          doc.enterEditMode("inPlace");

          doc.selectAll();

          doc.align("left", true);

          doc.align("top", true);

          doc.exitEditMode();

          doc.selectNone();

    }

}

main();

I hope this helps.

Regards,

JC

2 replies

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
October 31, 2018

Hi.

It's because the steps recorded can only take into account one instance. There's no instruction to get another instance and execute the same steps to it.

You need to go one step further and customize the command directly in a JSFL file.

Here is a suggestion.

JSFL script download:

animate_cc_jsfl_align_children_to_the_top_left.zip - Google Drive

Please save the JSFL file in the default commands folder because if you try to run the script from another folder Animate CC may crash.

Commands folder (Windows 10):

<DRIVE>:\Users\<USER>\AppData\Local\Adobe\<FLASH OR ANIMATE NAME AND VERSION>\<LANGUAGE>\Configuration\Commands

Example:

C:\Users\Admin\AppData\Local\Adobe\Animate CC 2019\en_US\Configuration\Commands

Mac OS® X:

Macintosh HD/Users/<username>/Library/Application Support/Adobe/Flash CS5/<language>/Configuration/Commands

I'm not a mac user. I took the location from here.

JSFL code (for reference only):

function main()

{

    var doc = an.getDocumentDOM();

    var selection;

    if (!doc)

    {

          alert("Please open a FLA first.");

          return;

    }

    selection = doc.selection;

    if (selection.length == 0)

    {

          alert("Please select at least one symbol instance first.");

          return;

    }

    doc.selectNone();

    for (var i = selection.length - 1; i >= 0; i--)

    {

          var instance = selection;

          if (instance.instanceType != "symbol")

              continue;

          instance.selected = true;

          doc.enterEditMode("inPlace");

          doc.selectAll();

          doc.align("left", true);

          doc.align("top", true);

          doc.exitEditMode();

          doc.selectNone();

    }

}

main();

I hope this helps.

Regards,

JC

IbarimAuthor
Inspiring
October 31, 2018

Hi, thanks

Your script works for me but only for instances of MCs. I thought I can set x any y on pics inside movieclips in library. But with this script I have to put ale movieclips on main stage, then use your script on all selected instances, and this way it changes my objects in library. Then I can remove the instances from main stage.

Still it saves me a lot of time so I don't have to change them each separately. Thank you again

JoãoCésar17023019
Community Expert
Community Expert
October 31, 2018

Excellent!

I may be able to come up with a solution for library items. If so, I'll get back to you.

Regards,

JC

IbarimAuthor
Inspiring
October 31, 2018

Ok, so changing x and y might create a problem, but I think it will be easer with 'align' command. Align command require selection so I have to do:

1 select a MC

2 click on stage to have no selection

3 ctrl + A to select all

4 align top

5 align left

(I can skip 2 and 3 but it gives me the same situation as I described below)

Then in history menu I select steps 2-5 and create a command task. I can use this task for one selected MC in library and it works fine. But when I select many MCs in library it doesn't work, error showing that "align function need selection".

So the problem is why this task does not select anything when applying command to multiple MCs, while it works for one MC?