/    Sign up×
Community /Pin to ProfileBookmark

preloading problems/script conflict?

either my preloader isn’t working, or it’s not working fast enough! if you go here [url]http://www.kasharocks.com/xfactor[/url]. you may or may not see the rollovers (there’s some on the top right menu, the left side image, and all along the “additions” panel).

i suspect that the preload script in the header:

function preloader()
{
var i = 0;
imageObj = new Image();
images = new Array();
images[0]=”logo_on.jpg.jpg”
images[1]=”slideshow.gif”
images[2]=”cycle_on.jpg.jpg”
images[3]=”djk_on.jpg.jpg”
images[4]=”elg_on.jpg.jpg”
images[5]=”soc_on.jpg.jpg”
images[6]=”portfolio_on.gif”
images[7]=”main_on.gif”
images[8]=”resources_on.gif”
images[9]=”profile_on.gif”

for(i=0; i<=9; i++)

{
imageObj.src=images[i];
}

is either interfering with this: [url]http://www.kasharocks.com/xfactor/javascript/xfactor.js[/url] or this [url]http://www.kasharocks.com/xfactor/javascript/images.js[/url]

i’d appreciate any help, thanks!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisNov 27.2006 — That is not a good preloading script. What happens with that script is that the loading of some images will be cancelled because they did not complete before the next preload request was made. Potentially, only the very last image in such a script will actually and succesfully get loaded.
Copy linkTweet thisAlerts:
@kashaauthorNov 27.2006 — what then, how about this one? it was what I had originally but still had the same problem.


if (document.images)

{

preload_image_object = new Image();

URL_prefix = 'http://www.kasharocks.com/xfactor/images';

// set image url
image_url = new Array();
image_url[0] = URL_prefix+"1.gif";
image_url[1] = URL_prefix+"2.png";
image_url[2] = URL_prefix+"3.png";

for(i=0; i<=2; i++)
{
preload_image_object.src = image_url[i];
}

}
Copy linkTweet thisAlerts:
@so_is_thisNov 27.2006 — Yes, that one does the same thing. It is re-using the same [B]Image()[/B] object -- which cancels the loading of any image not yet completely loaded.
Copy linkTweet thisAlerts:
@kashaauthorNov 27.2006 — well so_is_this, I just wanted to thank for the time you've taken answering my posts, you've been a great help (seriously, no sarcasm intended). yes, I will go through the code, and yes, i will finally learn how to do a *$%&$ javascript preload. in the meantime, here's a script for you my friend:

#preload { height: 0; overflow: hidden; }

<div id="preload"><img src="..." /><img ... ></div>

and that's that! have a nice day.
Copy linkTweet thisAlerts:
@so_is_thisNov 27.2006 — Nothing so mysterious about it. All you had to do was ask.

You should be able to just change this (from your first example):

imageObj = new Image();

to this:

imageObj = new Array();

and this:

imageObj.src=images[i];



to this:



imageObj[i] = (new Image()).src = images[i];
Copy linkTweet thisAlerts:
@kashaauthorNov 28.2006 — nope. still not working.

var i = 0;

imageObj = new Array();

images = new Array();

images[0]="logo_on.jpg"

images[1]="slideshow.gif"

images[2]="cycle_on.jpg"

images[3]="djk_on.jpg"

images[4]="elg_on.jpg"

images[5]="soc_on.jpg"

images[6]="portfolio_on.gif"

images[7]="main_on.gif"

images[8]="resources_on.gif"

images[9]="profile_on.gif"

for(i=0; i<=9; i++)

{

imageObj[i] = (new Image()).src = images[i];

}
×

Success!

Help @kasha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...