Highlighted

Strange behavior when converting layers in Animate 2019

Community Beginner ,
Jul 18, 2019

Copy link to clipboard

Copied

Hi all,

I'm migrating several project from Flash to Animate 19.2 (Build 405) and I've noticed the strange API's behavior described below.

Basically I have few layers with layerType = 'mask' and layerType='masked'. Using the API I'm looping through the layers and converts them to layerType = 'normal'. After that I'm publishing the file to HTML/JavaScript export with document.publish(). In the published files there is no logic for handling masks (i.e. everything is movie clips), as I've converted all layers to type = 'normal'.

Everything works as expected and there were no differences when using Flash or Animate 18.0.1 (Build 115) to do the exports.

In Animate 19.2 however I see some inconsistency. Sometimes the publish process works as mentioned/expected above and sometimes the published file contains the logic for masks, as if I haven't changed anything through the API. Moreover I've checked the FLA file after the publishing process and the layers were actually converted to type = 'normal', however this was not reflected in the published JS file.

I'm trying to identify a pattern when the publish process works as expected and when it does not, but with no success.

I've also tried all options with fl.clearPublishCache(); fl.publishCacheEnabled(); etc, but they don't work either.

Is anyone else aware of this inconsistency?

Thank you.

Hi,

Yeah, there is some kind of "quantum indeterminacy" in the nested symbols, changed by JSFL. You need to assure by your own eyes, that the changes are there, and they will be there

It is not sufficient to make a change in the nested symbol, the symbol must be "opened for editing" before that. So, I think, you need to do something like this:

- As a last point in your procedure, before saving the file, iterate through all items in the library, open each item via library.editItem() and make the changes while the item is open.

I think, your code will work with one-two little additions:

// Pass the library object itself as a fourth parameter

document.library.items.forEach( function( item, index, collection, library ){ 

     if ( !item.timeline ) return;

// Open the item for editing before you make any changes in it

lib.editItem( item.name );

     var counter = 0;

     item.timeline.layers.forEach(function(layer){

          layer.name+= ('_' + counter);

          counter+=1;

     });

     item.timeline.addNewLayer('default layer');

     item.timeline.deleteLayer(item.timeline.currentLayer);

}, document.library );

Views

366

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

Strange behavior when converting layers in Animate 2019

Community Beginner ,
Jul 18, 2019

Copy link to clipboard

Copied

Hi all,

I'm migrating several project from Flash to Animate 19.2 (Build 405) and I've noticed the strange API's behavior described below.

Basically I have few layers with layerType = 'mask' and layerType='masked'. Using the API I'm looping through the layers and converts them to layerType = 'normal'. After that I'm publishing the file to HTML/JavaScript export with document.publish(). In the published files there is no logic for handling masks (i.e. everything is movie clips), as I've converted all layers to type = 'normal'.

Everything works as expected and there were no differences when using Flash or Animate 18.0.1 (Build 115) to do the exports.

In Animate 19.2 however I see some inconsistency. Sometimes the publish process works as mentioned/expected above and sometimes the published file contains the logic for masks, as if I haven't changed anything through the API. Moreover I've checked the FLA file after the publishing process and the layers were actually converted to type = 'normal', however this was not reflected in the published JS file.

I'm trying to identify a pattern when the publish process works as expected and when it does not, but with no success.

I've also tried all options with fl.clearPublishCache(); fl.publishCacheEnabled(); etc, but they don't work either.

Is anyone else aware of this inconsistency?

Thank you.

Hi,

Yeah, there is some kind of "quantum indeterminacy" in the nested symbols, changed by JSFL. You need to assure by your own eyes, that the changes are there, and they will be there

It is not sufficient to make a change in the nested symbol, the symbol must be "opened for editing" before that. So, I think, you need to do something like this:

- As a last point in your procedure, before saving the file, iterate through all items in the library, open each item via library.editItem() and make the changes while the item is open.

I think, your code will work with one-two little additions:

// Pass the library object itself as a fourth parameter

document.library.items.forEach( function( item, index, collection, library ){ 

     if ( !item.timeline ) return;

// Open the item for editing before you make any changes in it

lib.editItem( item.name );

     var counter = 0;

     item.timeline.layers.forEach(function(layer){

          layer.name+= ('_' + counter);

          counter+=1;

     });

     item.timeline.addNewLayer('default layer');

     item.timeline.deleteLayer(item.timeline.currentLayer);

}, document.library );

Views

367

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
Jul 18, 2019 0
Adobe Community Professional ,
Jul 18, 2019

Copy link to clipboard

Copied

what happens if you use two different jsfl files, one to convert your layers and then save your new fla and a second jsfl to publish?

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
Reply
Loading...
Jul 18, 2019 0
Community Beginner ,
Jul 18, 2019

Copy link to clipboard

Copied

Hi kglad,

It is the same thing. I've even tried to make the changes with the code. Save the file manually. Publish the file with the code, but with no success.

After a few more test I believe I found a pattern:

1. Manually rename a layer in nested movie clip with layerType='mask' (suppose I'm doing some manual work/change to the file)

2. Go to the top level of the file (Scene) and save the *.FLA file manually

3. Change layers type to layerType = 'normal' using the API (layer.layerType = 'normal';). Also rename the layer using the API.

4. Publish the files to a HTML/JavaScript export type by executing document.publish();

In the published JS file you can see that some of the objects(layers) are still masks, not simple movie clips/objects. Also in the JS file where the layer names are commented out, you can see the names from step 1 (i.e. the changes form step 3 were not reflected in the published file). However if you open the *.FLA file you can see that the layers were renamed and converted to type='normal'.

If you do the same steps but without saving the file at step 2, the the output JS will not have logic for masks, but all layers consist simple movie clips and aslo the commented out names in the JS file are as per step 3.

I think it is something to do with saving the file and Animate keeping some cache, but I'm not sure.

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
Reply
Loading...
Jul 18, 2019 0
Adobe Community Professional ,
Jul 18, 2019

Copy link to clipboard

Copied

save the first converted layer file with a different name.  that will obviate any cache problems.

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
Reply
Loading...
Jul 18, 2019 0
New Here ,
Jul 18, 2019

Copy link to clipboard

Copied

Hi kglad,

I've done the following (hope I understand you correct)

I've done all the renaming/conversions in the main document, then:

1. document.save(); //

2. document.saveAsCopy(tmpDocPath); // where tmpDocPath is some file name (not the same as the original document)

3. fl.openDocument(tmpDocPath);

4. document.publish(); // The active document is tmpDocPath

I've tried with and without step 1 and again with not success. The problem with the JS still exists.

The interesting thing is that I can see the changes in the original FLA file, but the one I've saved as copy (tmpDocPath) does not have the changes. Event though I have executed the steps in the above order.

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
Reply
Loading...
Jul 18, 2019 0
Adobe Community Professional ,
Jul 18, 2019

Copy link to clipboard

Copied

are you using two different jsfl files executed at different times so there's timing issue.  ie,

1. open your original fla>execute your layer change jsfl and save with a new name.

2. open the newly named fla and execute your 2nd 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
Reply
Loading...
Jul 18, 2019 0
Community Beginner ,
Jul 19, 2019

Copy link to clipboard

Copied

Hi kglad,

Yes, and I've tried other things as well. Nothing works for as of now. I tried to simply rename the layer without converting it from mask to normal and result was the same.

I've narrowed it down to the following:

1. Open the original file and don't make any manual changes to it but just execute the script which simply renames the layers and save both the original file and the new one.

2. In both original file and the new one I can see that the layers are renamed which is the expected behavior.

1. Open the original file, make some manual changes to it and save the file (either manually or with the script).

2. Execute the script which simply renames the layers and save both the original file and the new one.

3. In the original file I can see the changes, but in the newly created one there are no changes an it looks like after executing step 1 (i.e. without the script changes). Here there is an issue, as the newly file should be a copy of the original one.

Does anyone knows where Adobe keeps its cache? If it is indeed a caching issue I'll try to deleted the cached files and see what will happen.

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
Reply
Loading...
Jul 19, 2019 0
Guide ,
Jul 19, 2019

Copy link to clipboard

Copied

Hi mate,

It's a long topic and I've only skimmed the discussion before, but at this stage it starts to seem to me that you are facing a well-known problem where Flanimate does not save changes made in files with JSFL if these symbols were not entered on stage one by one and altered in some other way.

This was implemented in CS6 if I'm not wrong as some form of 'fast save optimization'.

One way to sort the issue in CC is to manually generate a "Modify FLA Document" step in History by going to the Modify > Document... menu and just pressing OK in the dialog. After that Animate will re-write all the content and save the changes.

Unfortunately this cannot be done via code.

What we ended up doing as a workaround is the script has to recursively enter each modified symbol and create some change in it like creating and deleting a layer which slows down performance significantly, but ensures that the changes are saved.

Vladin M. Mitov​ may cast more light over the issue.

I wrote about where some of the cache is in this article. But it probably won't lead you anywhere.

Hope this is somehow helpful!

ps. I intend, when time permits, to report this to the dev team.

- Nick: Character designer and animator, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

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
Reply
Loading...
Jul 19, 2019 0
Community Beginner ,
Jul 19, 2019

Copy link to clipboard

Copied

Hi n. tilcheff,

Thank you too for responding. I think I see what you mean by "recursively enter each modified symbol and create some change in it", as I inherited this project and I see some lines with/adding deleting layers. However this doesn't help either. I've created a code snipped which everyone can test by themselves and see what I mean. You only need to have a symbol which is nested in a another one (hope I expressed myself correct. Also I'm not sure it this requirement is needed for reproducing the bug).

Basically you open the file and make some manual changes to it, then save and run the script. In that case you'll see that in the copied file there are no changes from the script, but the original file they exist.

If you don't do the above but just run the script, you see the script changes in both files.

Another thing to note is that everything works OK in Flash CC 2015 and in Animate CC 2018. The problem occurs in Animate CC 2019, so I think this is something new.

var document = fl.getDocumentDOM();

document.library.items.forEach(function(item) {

     if (!item.timeline) return;

     var counter = 0;

     item.timeline.layers.forEach(function(layer){

          layer.name+= ('_' + counter);

          counter+=1;

     });

     item.timeline.addNewLayer('default layer');

     item.timeline.deleteLayer(item.timeline.currentLayer);

});

tmpDocPath = 'URI tmp file path';

document.save();

document.saveAsCopy(tmpDocPath);

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
Reply
Loading...
Jul 19, 2019 0
Participant ,
Jul 21, 2019

Copy link to clipboard

Copied

Hi,

Yeah, there is some kind of "quantum indeterminacy" in the nested symbols, changed by JSFL. You need to assure by your own eyes, that the changes are there, and they will be there

It is not sufficient to make a change in the nested symbol, the symbol must be "opened for editing" before that. So, I think, you need to do something like this:

- As a last point in your procedure, before saving the file, iterate through all items in the library, open each item via library.editItem() and make the changes while the item is open.

I think, your code will work with one-two little additions:

// Pass the library object itself as a fourth parameter

document.library.items.forEach( function( item, index, collection, library ){ 

     if ( !item.timeline ) return;

// Open the item for editing before you make any changes in it

lib.editItem( item.name );

     var counter = 0;

     item.timeline.layers.forEach(function(layer){

          layer.name+= ('_' + counter);

          counter+=1;

     });

     item.timeline.addNewLayer('default layer');

     item.timeline.deleteLayer(item.timeline.currentLayer);

}, document.library );

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

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
Reply
Loading...
Jul 21, 2019 1
Community Beginner ,
Jul 23, 2019

Copy link to clipboard

Copied

Hi Vladin,

Thank you for suggestion.

I've tested it and it works indeed!

Hopefully the devs from Adobe will release a fix for this bug at some point.

Thank you everyone for helping!

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
Reply
Loading...
Jul 23, 2019 2
kglad LATEST
Adobe Community Professional ,
Jul 24, 2019

Copy link to clipboard

Copied

if you found a bug, it would help everyone if you report it, Feature Request/Bug Report Form

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
Reply
Loading...
Jul 24, 2019 0