These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Console output var has no properties

subieguy2
Registered: Apr 30 2009
Posts: 15

OK I can't figure out why my script does this?

I am creating some buttons with an array like so....(please keep in mind that I have a lot more "grid buttons" but to somewhat simplify this I have condensed it down to just a few.)
var gridButton = new Array();

// A
gridButton[0] = "a_01_grid";
// B
gridButton[1] = "b_01_grid";
// C
gridButton[2] = "C_01_grid";

// Callout Button Specs
var w = 44.65; // Constant - Width of Buttons
var h = 10.21; // Constant - Height of Buttons
var x = 120; // Starting X Coordinate ( Set this to the desired starting postion - width )
var y = 750; // Starting Y Coordinate
var cols = 5; // Constant - Number of Columns desired
var k = 0; // Counter for the Number of Buttons
var gap = 50; // Space in between rows

for (var i=0;i<(gridButton.length/cols);i++) // This loop executes once for each row of buttons
{
for (var j=0; j

My Product Information:
Acrobat 3D 8.1.2, Windows
nixopax
Registered: Feb 6 2009
Posts: 105
Generally, when you get the error message that: "g has no properties" it means that the object field does not exist. Ensure you haven't made any typos in the field names with the getField() construct.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
I would look at the limit item of your for loops, 'i<(gridButton.length/cols)'. You could also add some 'console.println()' statements to print out your conrol vlaue so you can see what is happening as the script runs.
var gridButton = new Array("a_01_grid","b_01_grid","C_01_grid"); // Callout Button Specsvar w = 44.65; // Constant - Width of Buttonsvar h = 10.21; // Constant - Height of Buttonsvar x = 120; // Starting X Coordinate ( Set this to the desired starting postion - width )var y = 750; // Starting Y Coordinatevar cols = 5; // Constant - Number of Columns desiredvar k = 0; // Counter for the Number of Buttonsvar gap = 50; // Space in between rowsconsole.show(); // show consoleconsole.clear(); // clear consoelconsole.println('gridButton.length/cols: ' + (gridButton.length/cols) ); // i control valuefor (var i=0;i<(gridButton.length/cols);i++) // This loop executes once for each row of buttons{console.println('i: ' + i); // i iterationfor (var j=0; j<cols; j++) // This loop executes once for each column of buttons{console.println('j: ' + j); // j interationvar aRect = [x + w +(j*gap),y,x+w+w+(j*gap),y-h]; // Rect = [upper-left x, upper-left y, lower-right x, lower-right y]if(k<gridButton.length){var f = this.addField(gridButton[k], "button", 1, aRect); // Draws Button "k" given the dimensions of the new rectanglef.setAction("MouseUp", "this.gotoNamedDest('a_04');");f.userName = "Schematic Location";}k++; // Moves on to the next button}y-=15; // Moves us down to the next Row}

George Kaiser

nixopax
Registered: Feb 6 2009
Posts: 105
Oh, I see something that could be the issue:

gridButton[2] = "[b]C[/b]_01_grid";
...
var g = this.getField("[b]c[/b]_01_grid");
g.setAction("MouseUp", "this.gotoNamedDest('c_01');");
g.userName = "Schematic Location";

Notice the C? JavaScript is case sensitive.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You will never get there. The value of 'gridButton.length/cols' is less then 1 (3/5), so the first loop does not even execute.

George Kaiser