Skip to main content
Silly-V
Legend
August 11, 2015
Question

Javascript enumerated objects

  • August 11, 2015
  • 1 reply
  • 1053 views

Hi everyone, this is a question which has to do with the enumerated objects in the javascript model such as "ElementPlacement.INSIDE" or, "Justification.CENTER".

Here is the thing, we have plenty of these objects available to us, and alerting the value of a textFrame.paragraphs[0].paragraphAttributes.justification will yield something like "Justification.CENTER".

In the OMV, the Justification object contains plenty of enumerated values such as CENTER:int, Value:2  and FULLJUSTIFY:int, Value 6.

Now, when I write something like this,

    var Colors = {

        BLUE: 1,

        GREEN: 2,

        ORANGE: 3

    };

    var item = {};

    item.color = Colors.ORANGE;

    alert(item.color);

Of course, my alert does not say "Colors.ORANGE", it says "3".  But, when you alert a justification of a paragraph, it will not say a number, but an object.

Can anyone explain to me what their special objects have that mine don't?

This topic has been closed for replies.

1 reply

Silly-V
Silly-VAuthor
Legend
August 12, 2015


Oh thank goodness my ESTK still works on my CS5, with the breakpoints and data-browser.
From this data-browser exploration, I can tell that the Justification object contains a bunch of objects itself, but still not sure about the whole thing, either - like how you can alert the integer value from alert(Justification.CENTER).

CarlosCanto
Community Expert
Community Expert
August 12, 2015

it may not be possible to get the enumerated values out of a native enumeration object, what are you trying to achieve?

Silly-V
Silly-VAuthor
Legend
August 12, 2015

Just some semantic help when writing code, and it seems to be a practice in ES which everyone must be familiar with, to do things such as set justification or element placement, so in my custom scripts I'd like to set this behavior the same way.

It isn't really needed, but also I wanted to get clarification on these objects because the OMV seems to show what I wrote with my Colors object above, but it does not, so I must be misunderstanding it. Then, when looking at the data browser, it's an answer which just asks more questions.