PDA

View Full Version : problem with loading bar


kwhubby
02-17-2003, 08:46 PM
hi, I have a loading bar in my game that I am making, that is only working on my computer (windows xp, with ie 6.0) I have been able to get no other computer to work, even an identical one.

it works sortov like this:
var imgss = new Array("asdf.gif","asdlkfas.gif","fdsa.gif")
var pos =0
var asdf = new Image()
asdf.src="abc.gif"
function load() {
if (asdf.complete) {
pos++
asdf.src = imgss[pos]
document.getElementById("bar").style.width = (pos*10)+"px"
}
if (pos < imgss.length) {
setTimout("load()", 10)
}
}
(in the body there is a bar using a colored<div> tag(<div id="bar" style=".....">))
the problem appears to be the .complete thing, it never becomes complete accept on my computer
check out the real example here (its not marked with notes so its kindov hard to find it and understand it)
http://kwhubby.8k.com/mr%20h/mr%20h.htm
:confused:

Graeme Hackston
02-18-2003, 12:38 AM
I'm on cable and didn't see the progress bar. I've also only done it in an hta on my computer. Here's a couple things I found.

With lots of images the progress bar works better in it's own window. I'm using a showModelessDialog

Complete doesn't happen in perfect order. I gutted this bar

http://www.javascriptfr.com/article.aspx?Val=168

for IE only and altered it like this. This is in the popup, hence DA = parent

DA = dialogArguments

Last_Number = 0

function Monitor_Write(number) {
if (number > Last_Number) {
Last_Number = number
}
This_Number = Math.max(Last_Number, number)

document.getElementById('barMv').style.clip="rect(0 "+clipright+" auto 0)"
document.getElementById('barBg').innerHTML = 'writing image ' + This_Number
document.getElementById('prct').innerHTML = 'writing image ' + This_Number

clipright = Math.floor(widthIE * This_Number / DA.Imgs.length + 1)
}

<edit>correction in bold</edit>

Graeme Hackston
02-18-2003, 12:51 AM
Sorry, Monitor_Write(number) is from inside the loop we discussed here.

http://www.codingforums.com/showthread.php?s=&threadid=14018

Progress_Window.Monitor_Write(i + 1)

Graeme Hackston
02-18-2003, 12:59 AM
Just to add. To make it work with lots of images, you need 2 stages. Monitor_Read(number) and Monitor_Write(number) The first being dumped into a hidden div. I works out for the better because you can change what you like in stage 2 and the whole thing is just as fast as PSP on my CPU

kwhubby
02-18-2003, 05:32 AM
Although I am using this with an array of images, setting one image at a time and waiting until it loads, and then changing to the next one. Do I have to actualy put the images into a hidden div, I can't just load them with javascript as a image variable (eg var x = new Image; x.src="asdf.gif"), It should work just fine if I load each image to a real image each turn, instead of an image "variable". Let me try it and see if it works on my computer (the non working one does work on my computer though ?)
ill be back in like 15 - 30 minutes maby
(its 9:31pm, pacific)

kwhubby
02-18-2003, 05:47 AM
ok go back and see if it works now with your computer (make sure its ie 5.0+, I don;t care about netscape and ie 4)

Graeme Hackston
02-18-2003, 05:52 AM
Yes it will work with a single load. I just wanted to clearify that. I'm resizing them on the way in and found that if I loaded 20 or more medium size jpgs IE started breaking down. It would render them at a fraction of the size I wanted.

Sorry it's much later here, post your findings and I'll catch up tommorow.

kwhubby
02-18-2003, 05:55 AM
i just wanted somebody to test it on a computer thats more picky with javascript than mine :)
http://kwhubby.8k.com/mr%20h/mr%20h.htm

Graeme Hackston
02-18-2003, 05:57 AM
Looks good, IE6 Win98

kwhubby
02-18-2003, 05:59 AM
yay!!!!!!!!!!!

:) :) :) :o :p :D :D

thanks for the help:thumbsup: ;)