Skip to main content
neonimator
Known Participant
Mar 16, 2023 1:09 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

    17 replies

    neonimator
    Known Participant
    Mar 18, 2023 7:09 PM UTC

    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)

    Translate
    kglad
    Community Expert
    Community Expert
    Mar 18, 2023 8:19 PM UTC

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

    Translate
    Vladin M. Mitov
    Inspiring
    Mar 16, 2023 2:39 PM UTC

    @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 );

     

    Translate
    - Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
    neonimator
    Known Participant
    Mar 16, 2023 2:59 PM UTC

    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?

    Translate
    kglad
    Community Expert
    Community Expert
    Mar 16, 2023 3:02 PM UTC

    afaik, the latest is only available online.

     

    and what fails to update immediately?

    Translate
    kglad
    Community Expert
    Community Expert
    Mar 16, 2023 1:33 PM UTC

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

    Translate
    neonimator
    Known Participant
    Mar 16, 2023 2:00 PM UTC

    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)

    Translate
    kglad
    Community Expert
    Community Expert
    Mar 16, 2023 2:10 PM UTC
    function createScene() {
        doc.addNewScene('New')
        end = scs.length
        cur = doc.currentTimeline
        doc.reorderScene(cur, end)
    tl = doc.getTimeline();
        tl.advancedLayersEnabled = true
    }
    Translate