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

Javascript enumerated objects

  • August 11, 2015
  • 1 reply
  • 1062 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 14, 2015

Not sure if this helps but I found this while looking for something else,

C:\Program Files\Common Files\Adobe\Scripting Dictionaries CC\illustrator 2015\omv.xml

excerpt about justification

<classdef name="Justification" enumeration="true">

      <shortdesc>The paragraph alignment.</shortdesc>

      <elements type="class">

        <property name="LEFT" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>0</value>

          </datatype>

        </property>

        <property name="RIGHT" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>1</value>

          </datatype>

        </property>

        <property name="CENTER" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>2</value>

          </datatype>

        </property>

        <property name="FULLJUSTIFYLASTLINELEFT" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>3</value>

          </datatype>

        </property>

        <property name="FULLJUSTIFYLASTLINERIGHT" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>4</value>

          </datatype>

        </property>

        <property name="FULLJUSTIFYLASTLINECENTER" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>5</value>

          </datatype>

        </property>

        <property name="FULLJUSTIFY" rwaccess="readonly">

          <datatype>

            <type>int</type>

            <value>6</value>

          </datatype>

        </property>

      </elements>

    </classdef>


Ahh, it is in the common files! I was wondering where that xml file lived. Thanks Qwertyfly...‌ ! Well, that's how the OMV gets its definitions.

For my purposes, next time I have a chance to use my own enumerated objects, I will see about using Carlos' approach.