Know when the game is ready from html/javascript

Get help using Construct 2

Post » Wed Oct 31, 2012 7:26 pm

I am trying to pass in some initial data to the game similar to this post:

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:

[CODE]iframe.onload = function()

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

[CODE]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
Posts: 20
Reputation: 2,378

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 9 guests