ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
launch script eval(file.read()) palette or dialog
on Mar 5, 2020 at 10:06:28 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".


Return to posts index

Andrei Popa
Re: launch script eval(file.read()) palette or dialog
on Mar 5, 2020 at 12:13:22 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.


Return to posts index

Scott McGee
Re: launch script eval(file.read()) palette or dialog
on Mar 5, 2020 at 1:59:20 pm

That makes sense.

Cheers for that.


Return to posts index


Scott McGee
Re: launch script eval(file.read()) palette or dialog
on Mar 9, 2020 at 9:53:54 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();


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]