Forum Discussion

GaryKenyon's avatar
GaryKenyon
Community Member
9 years ago

SL3 Javascript GetPlayer() function not defined in HTML5 output

Hi forum.

I created a game a while back for SL2, my external JS file gets and sets a bunch of Storyline variables using GetPlayer, SetVar and GetVar.

With the release of SL3, I have published this same game out, the Flash version works fine, the HTML5 version however, does not work. I am getting a ReferenceError on GetPlayer.

Does anyone know what the function to grab the SL player has changed to? I have gone through most of the given code, but I can't find any direct references to it anymore.

23 Replies

  • WillTribino's avatar
    WillTribino
    Community Member

    One way I managed to solve this is by calling a function from within Storyline that saves the player into a variable in the external js file. This way the player is only called when the player has been loaded for sure.

    Example:

    In an Execute Javascript trigger call the function (i.e when timeline starts execute js):

    callPlayer();

    In your JS external file have:

    function callPlayer(){

          window.player = GetPlayer();

    };

    By doing this you can call the player from within any other function in your external JS file, as long as the function is called from a trigger in SL.

    I´m sure that are other ways to manage the player around the iframe scope, but this is a simple way to avoid calling the player when it does not exist yet.

    I hope it helps.