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

Do an action using the state of an object on Captivate

New Here ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

Good Morning everyone,

I'm trying to create an action based on the status of an object: for example "IF the status of this object is A, then do this action". Do anyone know how (and if) is it possible to do this? I'm trying with conditional actions, but I don't know how to indicate the object status in the IF panel.

Thank you for the help

Views

558

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 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

That would require some JavaScript, as there's no System Variable that carries an object's current state. This forum post might help:

Is there a way to poll the current state of an object for use elsewhere?

Anyway, it might be worth considering to intercept the events that change the state in the first place, and track those changes in a tracking variable of some sort instead.

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
Community Expert ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

Or you could just do this with vanilla Captivate functionality by having a User Variable keep track of the object's state.  You just need to ensure that your Actions always assign the variable to have a value that corresponds exactly with the state of the object so that as the object's state is changed, so does the variable value.  You cannot currently check Object State in the decision block of a Conditional Action, and that's why you need to use the User Variable.

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 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

There's an even easier way, although still with JS:

var currentState = cp.getCurrentStateNameForSlideItem(targetID);

This gives the name of the current state of that target. Much easier than using the index of the state array.

So, to answer the OP, you can do this in JS to do something if an object named shape1 is in a particular state:

currentState = cp.getCurrentStateNameForSlideItem("shape1");

if(currentState == "state2"){

    cp.show("text2");

    cp.hide("text1");

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

}

If you want to use that state in an advanced action, send its value to a Captivate variable, var_myVar, for example:

The first line of your advanced action can be an Execute Javascript that says

window.var_myVar = cp.getCurrentStateNameForSlideItem("shape1");

Then you can use the variable var_myVar in the rest of the advanced action.

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
Community Beginner ,
Oct 04, 2021 Oct 04, 2021

Copy link to clipboard

Copied

LATEST

Thank you, that worked perfectly!

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