0

I'm using Javascript for InDesign scripting.

I have an image object and want to know it's bounds (the one that the user sees) -

bounds = (geometricBounds in image.parent)? image.parent.geometricBounds: image.geometricBounds;

returns ReferenceError - geometricBounds is undefined . This error comes when the parent to the image is an Oval object (So, I know geometricBounds property is there for an Oval object).

The problem is in (geometricBounds in image.parent) because when I alerted this statement, I got the same error. I'm surely missing something - because if this is not a property then I should simply get a false.

Any one knows why this is happening?

divyanshm
  • 6,600
  • 7
  • 43
  • 72

1 Answers1

2

The in operator checks for the property name as a string (in your case it is looking for a variable called geometricBounds - which which might contain the property name string - which is obviously not declared anywhere):

bounds = ('geometricBounds' in image.parent)? image.parent.geometricBounds: image.geometricBounds;
Daff
  • 43,734
  • 9
  • 106
  • 120
  • Uhh... I'm sorry, that was embarrassing. I'm new to JS - years of Java and C++, and now i feel dumb while doing JS! – divyanshm May 24 '13 at 13:23