Skip to main content
Inspiring
Oct 22, 2016 10:07 PM UTC
Question

Changing obect states with JS

I found this function elsewhere on the forum:  

cp.changeState("currentState,"newState");

So if my current state is "Normal" (Default) and the new state is called "Chosen" - I assume I can just add Javascript to a button with the line:

cp.changeState("Normal","Chosen");

 

And this should change the state on button click.

 

But this doesn't seem to work.  Could somebody explain where I'm going wrong?

 

 

 

 

 

    This topic is closed to new replies. Start a new post to keep the conversation going.

    6 replies

    Stagprime2687219
    Legend
    Mar 5, 2020 12:52 PM UTC

    You may also enjoy this resource with some basic JavaScript examples.

     

    Beginner's Guide to JavaScript 

    Translate
    Inspiring
    Mar 5, 2020 10:00 AM UTC

    It's actually cp.changeState("objectName","newState");

    Translate
    Claire_a_bradshaw
    Known Participant
    Mar 5, 2020 10:10 AM UTC

    Thanks for the reply - 

     

    cp.changeState("IR_Alpha","Normal (Default)"); <-- randomly tried this just in case... doesn't work
    cp.changeState("IR_Beta","onState"); <-- works
    cp.changeState("IR_Gamma","normal"); <-- doesn't work
    cp.changeState("IR_Xray","Orange"); <-- works

     

    So I can manipulate the states fine, but as the OP asked, how do you return to the default original state?

     

    thanks!

    Translate
    Inspiring
    Mar 5, 2020 10:24 AM UTC

    Make it "Normal" (with upper case N; and without the " (Default)" suffix). Should work.

     

    Translate
    Claire_a_bradshaw
    Known Participant
    Mar 5, 2020 9:33 AM UTC

    I need to do this too - any one solve this?

    Translate