Skip to main content
Participant
June 23, 2006
Question

Getting error when adding a simple javascript file to StartupScripts

  • June 23, 2006
  • 2 replies
  • 612 views
I am running Adobe Creative Suite 2 Bridge version 1.04 on a Mac OSX and I am getting a very consistent error when I add a javascript file to the StartupScripts directory.

Basically, if I put a file in the StartupScripts folder, found at ~/Library/Application Support/Adobe/StartupScripts/bridge/1.0, that modifies the navigation bars or updates the Favorites Pane, then it consistently requires me to reboot Adobe Bridge two times to successfully load the plug-in. On the first reboot, Bridge will display an error message saying, An error occurred while running a script. The script may not be compatible with this version of Bridge. Check for available updates by selecting the Updates command in the Help menu. And no plug-ins will be loaded. On the second reboot, Bridge will display another message saying, There were problems loading a startup script last time Bridge was launched. Would you like to load them now? Then if I press Yes everything will work fine and the next reboot will again display the error message, otherwise if I press No, the updates will not be loaded and the next reboot will ask if I want to load them now.

I wrote a very simple javascript file along the lines of:

var topBar = app.document.navbars.filesystem.top;
topBar.main = topBar.add( "panel", [5, 5, 760, 32], undefined);
topBar.main.address = topBar.main.add( "edittext", [3, 3, 600, 22],"");
topBar.main.browse = topBar.main.add( "button", [610, 3, 680, 22],"Browse");
topBar.main.go = topBar.main.add( "button", [690, 3, 740, 22],"Go");
topBar.visible = true;

If anyone knows what might be causing this problem, I would be very grateful.
Thanks.

Evan Appleby
Sony Pictures Imageworks
This topic has been closed for replies.

2 replies

Participant
June 26, 2006
You are absolutely right. That fixed the problem. Thank you for your help.
Participating Frequently
June 26, 2006
From what I can gather you have to wait for the document object to become initialised. If you have an event handler that waits for the document object to be created then you should be ok:

function buildIt()
{
var topBar = app.document.navbars.filesystem.top;
topBar.main = topBar.add( "panel", [5, 5, 760, 32], undefined);
topBar.main.address = topBar.main.add( "edittext", [3, 3, 600, 22],"");
topBar.main.browse = topBar.main.add( "button", [610, 3, 680, 22],"Browse");
topBar.main.go = topBar.main.add( "button", [690, 3, 740, 22],"Go");
topBar.visible = true;
}

onStartEvent = function(event)
{
if(event.object.constructor.name == "Document")
{
if(event.type == "create")
{
buildIt();
return {handled: false};
}
}
}

app.eventHandlers.push({handler: onStartEvent});