0

In the following function, the first debug output line ("debugPut"), produces what seems like a valid result:

X: 427 Y: 197src=http://www.mygameslab.com/Switch/settingsScreen.png

and even pasting the image link itself correctly displays the screen graphics.
However, the screen never displays and the next debug text which was supposed to print "Kukuriiiiiiku" doesn't seem to print anything - which implies to me that settingsScr never gets triggered.
Any idea what could be causing this?

Many thanks in advance if you try to help!

------------------------

function handleSettings() //Handles the settings screen
{
var settingsX = Math.floor((xSize-settingsScr.width)/2); //the centered X location of the settings window
var settingsY = Math.floor((ySize-settingsScr.height)/2); //the centered Y location of the settings window
document.getElementById("debugPut").innerHTML= ("X: "+settingsX+" Y: "+settingsY+"src="+settingsScr.src); // for debug

    settingsScr.onload = function ()        //make sure resource was loaded first
    {                               //shows the bg image only once it was loaded
        document.getElementById("debugPut").innerHTML= ("Kukuriiiiiiku"); // for debug
        gameBoard.drawImage(settingsScr,settingsX,settingsY);
        document.getElementById("debugPut").innerHTML= ("X2: "+settingsX+" Y: "+settingsY+"src="+this.src); // for debug

    };
}
2
Contributors
2
Replies
8
Views
3 Years
Discussion Span
Last Post by noobeyne
0

Found the solution: The problem was that by the time the execution got to this function, the item (settingsScr) was already loaded. That way, the onload event didn't fire and the function didn't occur.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.