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

Changing obect states with JS

Explorer ,
Oct 22, 2016 Oct 22, 2016

Copy link to clipboard

Copied

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?

 

 

 

 

 

Views

644

Translate

Translate

Report

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
Participant ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Engaged ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Participant ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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
Engaged ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

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
Participant ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

Result! 🙂 Works. Thanks! 

Votes

Translate

Translate

Report

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
Advisor ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

LATEST

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

 

Beginner's Guide to JavaScript 

Votes

Translate

Translate

Report

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
Resources
Help resources