Monday, December 26, 2005

How to Present an Object

An Object has many facets. It has a type that tells you what kind of object it is:
myObj.constructor.name;
For example, select a text frame in an InDesign document and run:
myObj = app.selection[0];
alert(myObj.constructor.name);
and you'll get an alert like this:



Notice both the absence of a space and the capitalization. A text frame object in JavaScript is a TextFrame kind of object, and yet, to refer to one, we use the spelling: textFrame. Which seems like a simple enough transformation until you run into objects like XML elements where the spelling transformation is less obvious.

0 Comments:

Post a Comment

<< Home