Built-In Namespace _global_
| Method Attributes | Method Name and Description |
|---|---|
|
onReady(handler)
Specify a function to execute when the DOM is fully loaded
|
Method Detail
onReady(handler)
Specify a function to execute when the DOM is fully loaded
Defined in: <build/melonJS-0.9.3.js>.
Defined in: <build/melonJS-0.9.3.js>.
// small main skeleton
var jsApp =
{
// Initialize the jsApp
// called by the window.onReady function
onload: function()
{
// init video
if (!me.video.init('jsapp', 640, 480))
{
alert("Sorry but your browser does not support html 5 canvas. ");
return;
}
// initialize the "audio"
me.audio.init("mp3,ogg");
// set callback for ressources loaded event
me.loader.onload = this.loaded.bind(this);
// set all ressources to be loaded
me.loader.preload(g_ressources);
// load everything & display a loading screen
me.state.change(me.state.LOADING);
},
// callback when everything is loaded
loaded: function ()
{
// define stuff
// ....
// change to the menu screen
me.state.change(me.state.MENU);
}
}; // jsApp
// "bootstrap"
window.onReady(function()
{
jsApp.onload();
});
- Parameters:
- {Function} handler
- A function to execute after the DOM is ready.