I have code that works perfectly when I run it from the document level of Acrobat Pro 8.0.
When I try to put it on the app.addToolButton function I keep getting undefined errors.
Could someone review my code and let me know how to appropriately apply it to a function call from the addToolButton?
This works from Document Level:
var page = this.pageNum;
var numWords = this.getPageNumWords(page);
for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(page, i);
var stringInt = parseInt(ckWord);
function buttonLocation(){
var q = this.getPageNthWordQuads(page, i);
m = (new Matrix2D).fromRotated(this,page);
mInv = m.invert()
r = mInv.transform(q)
r=r.toString()
r = r.split(",");
}
function makeCalloutButton(){
var l = this.addField(('000' + ckWord).substr(-3) + "_callout", "button", page, [r[4], r[5], r[2], r[3]]);
l.setAction("MouseUp", "this.callout" + ('000' + ckWord).substr(-3) + "();");
l.userName = "Machine Location";
}
function workMagic(){
buttonLocation();
makeCalloutButton();
}
function doTaps(){
if (ckWord == "AA") {workMagic();}
if (ckWord == "BB") {workMagic();}
if (ckWord == "CC") {workMagic();}
}
doTaps();
}
Then here is my code that DOES NOT work from executing the addToolButton:
app.addToolButton({
cName: "tapssMaker", // A name for your button
cExec: "taps();", //Function to Call
cLabel: "Taps", //The Text on the Button
cTooltext: "Make me some buttons please" //The Help Text
});
function taps(){
var page = this.pageNum;
var numWords = this.getPageNumWords(page);
for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(page, i);
var stringInt = parseInt(ckWord);
function workMagic(){
var q = this.getPageNthWordQuads(page, i);
m = (new Matrix2D).fromRotated(this,page);
mInv = m.invert()
r = mInv.transform(q)
r=r.toString()
r = r.split(",");
var l = this.addField(('000' + ckWord).substr(-3) + "_callout", "button", page, [r[4], r[5], r[2], r[3]]);
l.setAction("MouseUp", "this.callout" + ('000' + ckWord).substr(-3) + "();");
l.userName = "Machine Location";
}
function doTaps(){
if (ckWord == "AA") {workMagic();}
if (ckWord == "BB") {workMagic();}
if (ckWord == "CC") {workMagic();}
}
doTaps();
}
}