Forum Discussion
Changing state directly from JavaScript?
Hello Heroes!
Maybe someone out there can help me out! I've been playing with JavaScript and Storyline, you can see an example here: http://bit.ly/1IjNEKs.
But, what I can't figure out is how to access an object directly from JavaScript. I would like to change the state of a graphic from JavaScript.
In the example above, if you launch the course with adding ?test=Confused at the end of the URL link, and go to Chapter 3, the character will show the confused state. But essentially, I'm changing a variable first, which leads to a trigger to change the state. If I want ten different states, that's ten more manual triggers.
What I'd like to do is change the character's state directly. Any thoughts?
- MichaelHinzeCommunity Member
As far as I know, you can only pass variables between the player and SL content, but not directly access object properties. See here for a similar thread.
- PhilMayorSuper Hero
As Michael says no way to directly interact with objects you must use triggers to change the states
- ZsoltOlahSuper Hero
Thanks, guys! That's what I did but I wanted to make sure there's no better/easier way to accomplish it.
Glad you were able to get the assistance that you needed here Zsolt :)
- KristenGarciaCommunity Member
When is storyline going to allow a way to control objects on the screen with javascript instead of having to rely on triggers? Triggers can get so burdensome and jumbled and javascript is so much cleaner to use.... is this something that is being worked on?
Hi Kristen!
That's not something I've seen requested previously.
You are welcome to share your thoughts, ideas, and use-case with our team here.
- ChloeDesRocheCommunity Member
I agree with Kristen. The ability to access objects in addition to variables would be incredibly helpful! Being able to use javascript for repetitive tasks rather than creating a sequence of triggers to hide/show objects as variables change would save so much time and headache.
- BrandonEmersonCommunity Member
Agreed
- EthanEstes-00ceCommunity Member
I completely support this as well. It would also be nice to access these after output when debugging user issues!
- TonySundellCommunity Member
The more I keep stretching Storyline's limits, the more I have a need for this type of functionality. Just wanted to show my support to this particular feature.
- TerryBell1Community Member
Is there any update on this? I'd love to be able to get and set object states in javascript, so much easier to create and troubleshoot than multiple triggers!