Global variables without `window`?


Hi Everyone,

Can anyone tell me how I can create global variables without attaching them to window?
For example, how could I create a global GAME object that initializes variables when the Hype document first loads?


Another way to store data in the browser is to use LocalStorage. Check out this example from @MarkHunte:

(Hans-Gerd Claßen) #3

create one global object and assign vars and objects to it. just to reduce.

have a look at the hypeextensionsthread and you’ll find that it’ll be fine to just append your data to the hypeDocument.

hypeDocument.myGame = new Object();
hypeDocument.myGame.level = 1;
hypeDocument.myGame.myFunction = function(bla, blumm){return blumm}


Thanks for your replies, that’s very helpful!