Global variables without `window`?


#1

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?


#2

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}


#4

Thanks for your replies, that’s very helpful!