Looping an object to preLoad a list of images
<p>I have an object which carries images that i want to preLoad before i display them.</p>

<p>The info is stored like so:</p>

<pre><code> //var data =     ["images",{"ground":["0.png"]}]
</code></pre>

<p>I then want to loop them with an onLoad to be sure they are loaded so they will display... how ever they do not display on the first frame.... and im sure its because of the onLoad check.</p>

<p>This is what i have:</p>

<pre><code>function preLoad(data){
    gfx = new Array();
    count = 0;
    for(var i in data[1]){
        if (data[1].hasOwnProperty(i)) {
            ++count;

            gfx[i] = new Array();
            for(var j in data[1][i]){
                tmp = new Image();
                    tmp.onload = function(){
                        tmp.src = data[0]+'/'+data[1][i][j];
                        gfx[i].push(tmp);               
                }
            }           
        }   
    }

    window.gph = gfx;

    main();
}
</code></pre>

<p>Have i got this correct ?</p>
