Skip to main content
Known Participant
December 20, 2010
Answered

[JS CS5] How to get the selected state of a multi-state object

  • December 20, 2010
  • 1 reply
  • 638 views

Does anyone know if there is a way to identify which state of a multi-state object is selected?

You can select individual states of a multi-state object in the States panel.

In the Object Model,

myState = app.selection[0].states.item(0);

myState.active = true;

...displays the first state in the mso. But I can't figure out how to identify which state is currently visible. This doesn't seem to be possible in the object model, unless I'm missing something. Any ideas?

This topic has been closed for replies.
Correct answer tomaxxi

Hey!

Take a look at "activeStateIndex" of MSO.

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/

1 reply

tomaxxi
tomaxxiCorrect answer
Inspiring
December 20, 2010

Hey!

Take a look at "activeStateIndex" of MSO.

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/

Known Participant
December 20, 2010

Awesome, thanks Marijan! I was looking at the wrong object all along: The State object instead of the MultiStateObject!

tomaxxi
Inspiring
December 20, 2010

You are welcome Keith!

This also can help:

if(app.selection.length == 1 && app.selection[0] instanceof MultiStateObject){
    var myMSO = app.selection[0];
    alert("Selected state index: " + myMSO.activeStateIndex + "\r" +
    "State name: " + myMSO.states.item(myMSO.activeStateIndex).name);
}

--

tomaxxi

http://indisnip.wordpress.com/