I apply a setAction on bookmarks.
When I try to put all variables inside the object zoomSetter, then my code doesn't work.
But when I place the var. 'that' outside the object hence declaring it as a global var. it works fine.
Who can tell how to reduce the amount of global variables in a right manner?
Here the code being at Document-Level:
var that;
var zoomSetter ={
zoomer : function(mythisobj){
that = mythisobj;
var bmroot = that.bookmarkRoot;
var bmlength = bmroot.children.length;
for (var i=0;i < bmlength;i++){
var thebm = bmroot.children[i];
thebm.setAction("that.zoomType=zoomtype.fitW;");
}
} // End zoomer method
}; // End zoomSetter object
zoomSetter.zoomer(this);
For example:
var myObj = {
nCount:1,
Inc: function(){return ++this.nCount;}
}
myObj.Inc(); //Returns 2
Or you could do it like this
function Incrementer(nStart)
{
this.nInc = nStart;
this.DoInc = function(){return ++this.nInc};
}
var myInc = new Incrementer(3)
myInc.DoInc(); // Returns 4
In the functions, "this" is used to reference other members of the same object.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script