Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Callback Hell in After Effects Scripting with UI Palettes

  • Callback Hell in After Effects Scripting with UI Palettes

    Posted by Law Tan on May 25, 2025 at 2:02 pm

    Hi everyone,

    I’m new to scripting in After Effects and I’m working on a script where I need to let the user select layers, paths, or puppet pins by clicking on them.

    To guide the user through each step, I’m using palette windows — like in the function below:

    [code]

    function bloco() {

    var janela = new Window(“palette”, “—————————“, undefined);

    var texto = janela.add(“statictext”, undefined, “Select LAYER”);

    var botao = janela.add(“button”, undefined, “OK”);

    botao.onClick = function () {

    if (!tmpCompo || !(tmpCompo instanceof CompItem)) {

    return;

    }

    tmpLayer = tmpCompo.selectedLayers[0];

    if (!tmpLayer) {

    return;

    }

    janela.close();

    bloco2()

    };

    janela.center();

    janela.show();

    }

    [/code]

    The issue is that, in order to prevent the script from running to the end while waiting for user interaction, I’m calling the next function (bloco2() in this case) inside the onClick handler.

    This forces me to chain all my logic into nested callbacks, creating a kind of “function cascade” that’s becoming messy and hard to maintain.

    Is there a cleaner way to structure this kind of interaction in After Effects scripting? Ideally, I’d like to wait for the user input without turning the whole script into a chain of callbacks.

    I’m not sure if I explained this clearly.

    Thanks

    Roland R. kahlenberg replied 3 weeks, 3 days ago 2 Members · 1 Reply
  • 1 Reply
  • Roland R. kahlenberg

    May 28, 2025 at 11:15 am

    I’m not familiar too BUT I would look at using System/Script Prompts to proceed to the next stage.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy