Forum Discussion

SamClark's avatar
SamClark
Community Member
12 years ago

Storyline True/False variable comparison

UPDATE:

After further testing, I found that JavaScript setting a variable to "true" in Storyline ONLY FAILS IN HTML5.  All is well in the flash versions.  Simply put, a Storyline variable set "true" by JavaScript, e.g.,

GetPlayer().SetVar("MyTrue/FalseVar", true);

will NOT COMPARE EQUAL to True in Storyline when running HTML5.

For consistency's sake, I'll file a bug report.  I know of no way to get a true result in HTML5 using JavaScript now.  I have to resort to Numbers and ignore True/False variables.

Sam

  • TessaMaki's avatar
    TessaMaki
    Community Member

    I've never published anything to html5, but decided to play around with it today and try a course on an iPad. The course I have uses variables to track which slides the learner has visited, and then the final slide won't let them take the quiz if they haven't reviewed certain slides (The quiz is actually just a fake quiz used to track if they reviewed the few slides out of many that would be required in order for the course to track as complete).

    Anyway, the course worked great on the iPad except the final slide showed that I had not visited any of the slides. I signed into the course on a PC, and it accurately reflected what I had visited. I am using true/false variables to track this information.

    Am I understanding right, that if I used numeric instead of true/false, this should work on the iPad?

    This course was truly just a test, but I better figure this out now so I don't get myself into trouble in the future. Your input is much appreciated!

    ~Tessa

  • Hi all!

    I'm not pretty sure if I understood right the original post, but I used a javascript to change a true/false variable, with this piece of code:

    var player = GetPlayer();
    player.SetVar ("tru/false var",4

    and it works fine under html5... Of course, as we have a GetPlayer, it doesn't work under html...

    But I found something else, it seems that lightboxes doesn't work under html5??? Does anyone ever had this case?

  • With HTML5, quotes are required ("true" rather than true).

    GetPlayer().SetVar("varName",true); // does NOT work in HTML5 version.
    GetPlayer().SetVar("varName","true"); // works in HTML5 version.

    Here's another thing to watch out for with HTML5. Say you have a numeric variable in Storyline with default value 2.

    The typeof operator in JavaScript will return "string" (when checking that var using GetVar).
    BUT if you change the value of that variable from its default (with JavaScript or in Storyline) then typeof returns "number".

    For me, that means I must use non strict == instead of strict === when checking equality of a numeric var from Storyline with a number in JavaScript.

     

     

  • MichaelAmbech's avatar
    MichaelAmbech
    Community Member

    An update to my post:

    The issue is (partly) due to the fact that storyline isn't using true boolean values. True/False are presented as strings.

    However changing the variable to 0/1 and adjusting the code accordingly doesn't fix the issue.  Does the content part of pdfmake not support the use of if-statements?

    • JeffTas's avatar
      JeffTas
      Community Member

      Michael - did you get an answer to this ? I am doing something similar using pdfmake and only want variables to appear if their value is set to true in Storyline.