Note: This blog is sorta marketing-related and less frequently updated than other blogs that I author.
If you are more of a techy-geek than a marketing wizard then cre8ive hut
will be much interesting for you.
Volkan.
Volkan.
11.26.2005
A batch image preloader - js
The current project I'm working on requires some advanced preloading stuff and sardalya's Preloader is not enough.
I need to load an array of images as a batch.
Here is the current pseudocode in my mind:
var g_arImageURL={the url array}
var g_arObj={the object array}
var g_arImgRef=new Array();
var g_completedImageCount=0;
function startBatchPreload(){
for each url in g_arImageURL
....g_arImageRef.push(new Image(g_arImageURL[i])
trackPreloadProgress();
}
function trackPreloadProgress(){
for each image in g_arImageRef
....if image is complete
........change src of the g_arObj[i] to image.src
........g_completedImageCount++
if(g_completedImageCount less than total images)
....setTimeout(trackPreloadProgress,someInterval);
}
...
Or something more oo-ish:
function _BatchPreloader(){
....this._arImageURL=new Array();
....this._arObj=new Arrray();
....this._arImgRef=new Array();
....this._completedImageCount=0;
}
... other stuff ...
var BatchPreloader=new _BatchPreloader();
function BatchPreloader_TrackBack(){
... loop thru uncompleted images.
... if there are more images to preload then busy wait (i.e settimeout)
}
And if it's going to be an object, I shall find a better name for it.
Giving a name to an object you've just created is difficult in deed.
If you have children, just think how hard it was to pick up a name for them.
Of course, I don't say that my objects are like my children (well, sometimes they are actually :) ).
But you got the point, don't you?
After I'm done with this new preloader thingy I'll add it to sardalya as well.
But I have to finish the project I'm working on first: Although sardalya is my personal playground, my clients are my business. And since they give me the money, it is normal that they take precedence over other things.
However the relation is mutual:
The current project I'm working on will help me improve, test and benchmark sardalya as well.
So on one hand I gain money; on the other hand I find yet another real-life test platform for sardalya. Not a bad deal.
(note to myself : in the project ToolTip's bleeding issue over screen edges has to be fixed as well)
...
Just a final thing...
The project (the site I'm building to my current client) will be a secret until I totally finish it and upload to the production server.
After that, I'd like to share several interesting findings with you as well as compare and contrast the former and latter versions of the site.
The site is a real case study :)
I'm sure you'll enjoy when I share my findings.
Just wait for a few weeks.
I need to load an array of images as a batch.
Here is the current pseudocode in my mind:
var g_arImageURL={the url array}
var g_arObj={the object array}
var g_arImgRef=new Array();
var g_completedImageCount=0;
function startBatchPreload(){
for each url in g_arImageURL
....g_arImageRef.push(new Image(g_arImageURL[i])
trackPreloadProgress();
}
function trackPreloadProgress(){
for each image in g_arImageRef
....if image is complete
........change src of the g_arObj[i] to image.src
........g_completedImageCount++
if(g_completedImageCount less than total images)
....setTimeout(trackPreloadProgress,someInterval);
}
...
Or something more oo-ish:
function _BatchPreloader(){
....this._arImageURL=new Array();
....this._arObj=new Arrray();
....this._arImgRef=new Array();
....this._completedImageCount=0;
}
... other stuff ...
var BatchPreloader=new _BatchPreloader();
function BatchPreloader_TrackBack(){
... loop thru uncompleted images.
... if there are more images to preload then busy wait (i.e settimeout)
}
And if it's going to be an object, I shall find a better name for it.
Giving a name to an object you've just created is difficult in deed.
If you have children, just think how hard it was to pick up a name for them.
Of course, I don't say that my objects are like my children (well, sometimes they are actually :) ).
But you got the point, don't you?
After I'm done with this new preloader thingy I'll add it to sardalya as well.
But I have to finish the project I'm working on first: Although sardalya is my personal playground, my clients are my business. And since they give me the money, it is normal that they take precedence over other things.
However the relation is mutual:
The current project I'm working on will help me improve, test and benchmark sardalya as well.
So on one hand I gain money; on the other hand I find yet another real-life test platform for sardalya. Not a bad deal.
(note to myself : in the project ToolTip's bleeding issue over screen edges has to be fixed as well)
...
Just a final thing...
The project (the site I'm building to my current client) will be a secret until I totally finish it and upload to the production server.
After that, I'd like to share several interesting findings with you as well as compare and contrast the former and latter versions of the site.
The site is a real case study :)
I'm sure you'll enjoy when I share my findings.
Just wait for a few weeks.