Forum Discussion
New Storyline Javascript API
Hi all,
In the new Javascript APi You can call the state of an object. I assume you can also change the state of an object.
it tried it with code below:
const answerBlong = object('6bfhtnMG4nH');
answerBlong.state = "Selected";
And the console gave back (slides.min.js:2 no matching state "Selected") The object I refer to has a Selected stat among other states.
Anyone any idea what I do wrong?
Mark
3 Replies
- Jim_ArbonCommunity Member
I had a similar issue - I don't think it likes changing to a state that has a name that's the same as the built-in ones. Try a new custom state with a name like "SelectedSL" and it should work. I've got it to change states using this workaround.
Ideally they would fix this in a new release, because duplicating a state just for this is a pain.
- NedimCommunity Member
You’re not doing anything wrong. Only the Normal built-in state and custom states can be accessed via the object.state property by referencing the state name. Other built-in states (such as Hover, Visited, Selected) are not mapped in slides.js. These states are typically triggered natively by mouse events (like mouseover) or clicks, while custom states are explicitly triggered.
Example of an error when you try to set object.state = "Selected". You’ll encounter the same issue if you attempt to set object.state to "Visited" or "Disabled". However, object.state = "Normal" will work just fine.
The workaround:
object.state = "_default_Selected" - JoeFrancisCommunity Member
So we're back to creating all custom states for objects. Probably for the best anyway.