Skip to main content
Inspiring
July 8, 2023
Question

After effects scripting

  • July 8, 2023
  • 1 reply
  • 383 views

Hello

I have this simple code to create ui docable panel for after effects and i want to click the button and colse panel but it isn't working, any help? :

function createDockableUI(thisObj) {
var dialog = thisObj instanceof Panel ? thisObj : new Window("window", undefined, undefined, { resizable: true });
dialog.onResizing = dialog.onResize = function() { this.layout.resize(); };
return dialog;
}

function showWindow(myWindow) {
if (myWindow instanceof Window) { myWindow.center(); myWindow.show(); }
if (myWindow instanceof Panel) { myWindow.layout.layout(true); myWindow.layout.resize(); }
}

var win = createDockableUI(this);
var button1 = win.add("button", undefined, "TestMe");
button1.onClick = function() { win.close(); };
showWindow(win);

 

This topic has been closed for replies.

1 reply

Inspiring
July 8, 2023

I believe you can only close a window, not a docked panel. The script doesn't create the panel, it's given it by AE (which is what you pass in with 'this') so it makes sense that it wouldn't have control over closing it. If you run the script from File > Scripts > Run Script File then it's created as a window and it does close.

Inspiring
July 9, 2023

I've created my script, for the first time when it is run, it will show a login form with an OK and Cancel button. If the user chooses to hit the Cancel button, I want to close both the login form and the main script panel. That's why I want to close it.