I just want a button that says "Go!" and I cant get it

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Brandon_M
Posts: 2
Joined: February 5th, 2009, 6:51 pm

Can someone give me some bare bones code I could use that creates a button in my dockable window that when pressed will initiate the "script" ?

I am able to get the button up but have no idea how to tell it what to do when its clicked.

Still learning, but cant find ANYTHING on the ScriptUI stuff.

Thanks guys!
Yenaphe
Posts: 84
Joined: February 3rd, 2009, 6:30 pm
Location: Paris - France
Contact:

This piece of code should help you.

It creates a panel "YourPanel", with a button that execute the script linked to them in the "addscriptbutton" fonction. This code is based on one of the sample script provided with AE.

Code: Select all

{
	function onScriptButtonClick()
		{
			var scriptFile = new File(this.currentDirectory+this.scriptFileName);
			scriptFile.open();
			eval(scriptFile.read());
			scriptFile.close();
		}
	
	function addScriptButton(palette, buttonRect, buttonLabel, buttonCurrentDirectory, buttonScriptName)
		{
			var newButton = palette.add("button", buttonRect, buttonLabel);
			
			newButton.scriptFileName   = buttonScriptName;
			newButton.currentDirectory = buttonCurrentDirectory;

			newButton.onClick = onScriptButtonClick;
			return newButton;
		}

	function createUI(thisObj) 
		{
			var myPanel = ( thisObj instanceof Panel) ? thisObj : new Window("palette", "Your Panel Name", undefined, {resizeable:true});
			var Your_Button_Name = addScriptButton(myPanel,[topleft_x, topleft_y, bottomright_x, bottomright_y], "Your_Button_Label",  "Your_Script_Directory", "Your_Script_Filename");
                        //You can add how many buttons you want
			return myPanel;
		}
	
var YourPanel = createUI(this);

	if (YourPanel instanceof Window) YourPanel.show();

}

Enjoy :)

/Seb
Brandon_M
Posts: 2
Joined: February 5th, 2009, 6:51 pm

Oh great! Thanks I will go through it now.
Post Reply