Know when the game is ready from html/javascript

0 favourites
  • 1 posts
From the Asset Store
Ready to use construct 3 game template and release to mobile divice.
  • I am trying to pass in some initial data to the game similar to this post:

    http://www.scirra.com/forum/global-variables_topic50853.html

    However this example uses a button click and I am trying to do this onload

    I have a game that is being contained in an iframe and I am currently doing this from the parent:

    iframe.onload = function()
      {
         iframe.contentWindow.setVars();
      }
    

    The setVars function defined in the index.html used as the iframe src looks like this:

    function setVars(){     
                   var gameIDField = document.getElementById("gameID");
                   var gameID = "2";
                   gameIDField.value = gameID;
              }
    

    gameIDField is an offscreen textbox in the game with id "gameID"

    It seems that the onload is not enough to wait because I'm getting gameIDField as null. I would really like this to be event based if possible, maybe I'm just missing something.

    I have confirmed that this will set the text if forcing to script to wait a second or two, but this is not acceptable for a solution

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)