Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript enumerated objects

Valorous Hero ,
Aug 11, 2015 Aug 11, 2015

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?

TOPICS
Scripting
865
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Valorous Hero ,
Aug 11, 2015 Aug 11, 2015

Screen Shot 2015-08-11 at 7.14.51 PM.png
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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2015 Aug 12, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 12, 2015 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2015 Aug 12, 2015

I don't know why Enums are set up one way or another in a given DOM, for instance in vbs, Justification.CENTER is not allowed, we must use the index value 2. (also what we see in the OMV may not correct)

in javascript whenever I need to use the enum values dynamically, I build my own array to set up my values numerically.

var refpoint = [Transformation.DOCUMENTORIGIN, Transformation.TOPLEFT, Transformation.TOP, Transformation.TOPRIGHT, Transformation.LEFT, Transformation.CENTER, Transformation.RIGHT, Transformation.BOTTOMLEFT, Transformation.BOTTOM, Transformation.BOTTOMRIGHT];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2015 Aug 12, 2015

check this thread for a possible solution to finding out Enum values and indexes.

How can I access the int value of an enum?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 13, 2015 Aug 13, 2015

Thank you CarlosCanto‌ .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 13, 2015 Aug 13, 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 14, 2015 Aug 14, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines