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

Button Icons don't show.

DaHuuudge
Registered: Jul 5 2011
Posts: 2
Answered

The function below creates a working button but It doesn't display the Icons.
Where am I going wrong?
 
function forwardButSetUp(pg) {
var pgRect = this.getPageBox("Crop", pg);
var fldRect = [];
fldRect [0] = pgRect[0] + 700;
fldRect [1] = pgRect[0] + 70;
fldRect [2] = pgRect[0] + 760;
fldRect [3] = pgRect[0] + 10;
var f=this.addField( "nextPg","button",pg, fldRect);
loadIcons();
f.buttonSetIcon("fwdUp","0");
f.buttonSetIcon("fwdActive","1");
f.buttonSetIcon("fwdOver","2");
f.buttonPosition=position.iconOnly;
f.buttonScaleHow=scaleHow.proportional;
f.display = display.visible;
f.buttonScaleWhen = scaleWhen.always;
f.setAction("MouseUp", "this.pageNum++");
}

My Product Information:
Acrobat Pro 8.1, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The nFace value is an integer, not a string. Remove the quotes around it, and try again.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
Also, the first parameter, oIcon, is an Icon object, not just its name.
So, for example, your first line should actually be:

f.buttonSetIcon(this.getIcon("fwdUp"),0);

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

DaHuuudge
Registered: Jul 5 2011
Posts: 2
Thanks very much try67.

That was the stumbling block the 'object not just name' thing (I put the quotes round the nFace value in kinda bit-desperate-try-anything mode!) now made both changes and now it shows the default icon. However, I doesn't show the other Icons when rolled over and active - I will refer to the api manual to see if I can see how to set the button to 'push' behaviour.

Thanks again for helping me out.