Skip to main content
neonimator
Known Participant
March 16, 2023
Question

"advancedLayersEnabled" - doesn't work after "addNewScene"?

  • March 16, 2023
  • 3 replies
  • 1441 views

Hello!

If I use this option as part of a function, this line of code does not work.

Tried:
- move the code to the global scope
- fetch (forEach) the updated array

As if it doesn't see the scene just created and passes by.

In the case of a separate run from another file - it works. Even on scenes, which are created by the script.

var doc = fl.getDocumentDOM()
var tl = doc.getTimeline()
var scs = doc.timelines

createScene()
function createScene() {
    doc.addNewScene('New')
    end = scs.length
    cur = doc.currentTimeline
    doc.reorderScene(cur, end)
    tl.advancedLayersEnabled = true
}


This is important, because if I do "addItem" further in the script, the console writes: "Layer effects can only be seen when 'Advanced layers' mode is turned ON from document settings.

 

    This topic has been closed for replies.

    3 replies

    neonimator
    Known Participant
    March 18, 2023

    The answer to the topic question is - no, everything works. Just need to learn JS and API better. Thank you very much for your quick response! The topic can be closed)

    kglad
    Community Expert
    Community Expert
    March 18, 2023

    you're welcome, and i'm trying to help you write better code with the suggestions i've made.

    Vladin M. Mitov
    Inspiring
    March 16, 2023

    @kglad was faster than me and his suggestion is valid, but here's mine - a function with parameters for the name and state of advancedLayersEnabled.

    function createScene( aname, astate ){
    	
    	var doc = fl.getDocumentDOM(),
    		ns = doc.addNewScene( aname );
    	
    	if( ns ){
    		doc.getTimeline().advancedLayersEnabled = astate;
    		end = doc.timelines.length;
    		cur = doc.currentTimeline;
    		doc.reorderScene( cur, end );
    	}
    }
    
    createScene( "New Scene", true );

     

    - Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
    neonimator
    Known Participant
    March 16, 2023

    Thanks for the quick response, guys! Got it! Looks like it's really about the interface update, it doesn't immediately show the changes when the code is executed. Plus, the advanced layers are specific.

    P.S. Is the updated documentation still only on the web-archive or has a full PDF already appeared? Maybe at least a release date flashed?

    kglad
    Community Expert
    Community Expert
    March 16, 2023

    afaik, the latest is only available online.

     

    and what fails to update immediately?

    kglad
    Community Expert
    Community Expert
    March 16, 2023

    your timeline changes when you add scenes.  ie, update tl before enabling advanced layers in it

    neonimator
    Known Participant
    March 16, 2023

    Yes, probably, but how do you do it inside the code? Creating the scene is just the beginning of the script.

    By the way, in the past, for other purposes, tried to use the command "enterEditMode" - also feels like it loses layers and can't change properties. But if I click the mouse on the workspace and repeat the execution - it comes to life and is executed. But at this rate, no automation will not work)

    kglad
    Community Expert
    Community Expert
    March 16, 2023
    function createScene() {
        doc.addNewScene('New')
        end = scs.length
        cur = doc.currentTimeline
        doc.reorderScene(cur, end)
    tl = doc.getTimeline();
        tl.advancedLayersEnabled = true
    }