Ok, anyone have a clue as to why this probable bug or pissy annoyance is happening, i am all ears.
*Objective:*
Creating a Image Preloader in a DHTML application. It basically creates a splash screen, i feed in proposed assets to preload (js libs, images, html etc).
It will the loop through this array and preload each individual asset, once done it will then do a callback until all the assets within an array are fully complete. Basic enough concept.
*Problem:*
For some reason in Internet Explorer, if you assign the onload method to an internal method it will continue to execute onLoad endlessly!
*Proprosed Reason Why:*
I think that if you assign the oImage.onload = this.onAssetLoad it will effectively over-ride that method or something along those lines?
*Current Work-around:*
Its not elegant, but basically (looking at the code below) the only way to fix this endless cycle of onLoad shit, is to basically set the onLoad to null within the method that over-rides the onLoad. *Problem* the first asset gets loaded twice, while this probably isn't a big thing, but from a code elegance it sux.
*Ideal Solution:*
It would be great to subscribe to the onLoad method in some way? i.e. oImage.addEventListener("onload",myListenerObject);
*Does anyone have any possible solutions or JavaScript know-how on how to combat this problem, please speak up as its driving me crazy mkaaaaay.*
*Code:* LoadScreen.prototype.tmpDefinePreload = function() { var oAsset; var oAssets = new Array();
oAsset = new Object();
oAsset.type = "img";
oAsset.id = "InitScreen";
oAsset.uri = "/assets/backgrounds/Initscreen.gif";
aAssets.push(oAsset); oAsset = new Object();
oAsset.type = "img";
oAsset.id = "InitBar";
oAsset.uri = "/assets/animations/InitBar.gif";
aAssets.push(oAsset);
this.beginPreload(true);}
LoadScreen.prototype.beginPreload = function(aAssets) {
this.aAssetsToLoad = aAssets;
this.preloadAssets(true);
};
LoadScreen.prototype.preloadAssets = function(IsArrayFreshlNew) { if(!IsArrayFreshNew) {
this.aAssetsToLoad.shift();
}
if(this.aAssetsToLoad.length <= 0) {
this.aAssetsToLoad = new Array();
return null;
}
var currentAsset = this.aAssetsToLoad[0];
var oImage = new Image();oImage.controller = this;
oImage.onload = this.onLoadAsset;
oImage.id = currentAsset.id;
oImage.src = currentAsset.uri;
}
LoadScreen.prototype.onLoadAsset = function() {
// Insert this to fix the onload bug?
Debug.trace("Finished Loading " + this.id,"Info"); // Ignore this Debug statement, as i've written my own debug filter.
this.onload = null;
this.controller.preloadAssets(false);
};
--
Regards, Scott Barnes - http://www.mossyblog.com http://www.bestrates.com.au
--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
