I am sorry this is so specific...hope that's ok. I am having trouble figuring out how to move all this to the document level. Here is what I currently have at the document level...
// CALLOUT BUTTONS
// Sizes button
var initialPosition = [ 325, 700 ];
var w = 44.65;
var h = 10.21;
var vGap = 1;
var aRect = [initialPosition[0], initialPosition[1]-(h+vGap), initialPosition[0]+w, initialPosition[1]-h-(h+vGap)];
// 001_callout
var c001 = this.addField("001_callout", "button", 1, aRect);
c001.setAction("MouseUp", "this.gotoNamedDest('view_01');");
// 002_callout
var c002 = this.addField("002_callout", "button", 1, aRect);
c002.setAction("MouseUp", "this.gotoNamedDest('view_02');");
This works fine. It creates 2 buttons and names them. Then assigns them an action to go to a destination. I would like the script to check and see if the button exist first. If it does exist assign the actions. If it does not exist create it and then assign it the actions. Keep in mind that there could potentially be up to 130 buttons this script would create. Any suggestions on creating an array on this or whatever is more efficient would be great. Again I am a newbie and get by....but never claimed my scripts were efficient. :)
Then I have this script on a button (just to test the code). I would like to move it to the document level and assign this as an action for the first button "001_callout".
// Callout 1 layers - Turns off all layers except Callout 1 and Paste 1st (Data)
var CalloutOne = "Callout 1";
var PasteFirst = "Paste 1st";
var ocgArray = this.getOCGs(this.pageNum);
for ( var i=0; i < ocgArray.length; i++) {
if ( ocgArray[i].name == CalloutOne ) {
ocgArray[i].state = true;
}
else ocgArray[i].state = false;
}
for ( var z=0; z < ocgArray.length; z++) {
if ( ocgArray[z].name == PasteFirst ) {
ocgArray[z].state = true;
}
}
Over all what I want this to do is.....look to see if the button "xxx_callout" exist. If it DOES NOT exist....create it.
Once the button is created I want it to have actions assigned to it. I want it to go to "view_xx" and turn off all the layers on that page except for "Callout 1" and "Paste 1st".
Any help someone can provide would be greatly appreciated! Even if it is a small part of it...like writing an array to create the buttons instead of the long drawn out way.
PLEASE HELP!
THANKS IN ADVANCE!
I would settle for the name of a good book that will help me figure this out. please help!