Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions launch script eval(file.read()) palette or dialog

  • launch script eval(file.read()) palette or dialog

  • Scott McGee

    March 5, 2020 at 10:06 am

    So I have two scripts. One that opens the other.
    So I open this script.
    var w = new Window("palette","script",undefined);

    var btn = w.add("button",undefined,"Lauch");

    var file = new File("‎~/Desktop/test.jsx");

    btn.onClick = function(){
    if(!file.exists){
    alert("WRONG LOCATIONS")
    }
    file.open("r");
    eval(file.read());
    file.close();
    }

    w.show();
    Nothing special. Then I click the button and it opens the below script.
    var w = new Window("dialog","script",undefined);

    var btn = w.add("button",undefined,"TEST");

    w.show();

    Now if I use “dialog”, works fine. If I change it to palette. Not fine…Anyone know why this is? And how I can use “palette”.

  • Andrei Popa

    March 5, 2020 at 12:13 pm

    First, I would put an else after checking if the file exists. So the script doesn’t try to open the next script.

    Then, I think(not by far sure) that what happens is that you declare the second window inside the button variable. So i think the scope is what makes you trouble. I thin dialog has direct scope to the main app or something(since you can;t have 2).

    Long story short, if you declare your second window inside the main program, it works.

    File 1 :
    var w = new Window("palette", "script", undefined);
    var w2 = new Window("palette", "script", undefined);

    var btn = w.add("button", undefined, "Lauch");

    var file = new File("‎~/Desktop/test.jsx");

    btn.onClick = function () {
    if (!file.exists) {
    alert("WRONG LOCATIONS")
    } else {
    file.open("r");
    eval(file.read());
    file.close();
    }

    }

    w.show();

    File 2:
    var btn = w2.add("button",undefined,"TEST");

    w2.show();

    Andrei
    My Envato portfolio.

  • Scott McGee

    March 5, 2020 at 1:59 pm

    That makes sense.

    Cheers for that.

  • Scott McGee

    March 9, 2020 at 9:53 am

    Tomas on the adobe forums posted this and it appears to work, when doing a few tests with it.
    He said he couldn’t explain why it worked, just that it does.

    var w = new Window("palette", "script", undefined);
    var btn = w.add("button", undefined, "TEST");

    w.onResizing = function() {
    this.layout.resize();
    };

    w.show();

Viewing 1 - 4 of 4 posts

Log in to reply.

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