Can Somebody Check This?

C

chris

I'm trying to create a script that will cycle through a bunch of pics
(1.jpg, 2.jpg, and so on up to 429.jpg) to make a movie. However, I
can't get it to work. Could someone tell me what I'm doing wrong?
Here it is...

<html>

<head>

<script>
pics = new Array()
curPic = 0

preLoad() {
for (i=0; i <= 429; i++) {
pics = new Image()
pics.src = i + ".jpg"
}
}

dispPic() {
document.images['moviePic'].src = curPic + ".jpg"
curPic++
setTimeout("dispPic()", 20)
}
</script>

</head>

<body>

<body onload="preLoad(); dispPic()">

<img src="1.jpg" name="moviePic" width="640" height="416">

</body>

</html>
 
E

Evertjan.

chris wrote on 03 mei 2004 in comp.lang.javascript:
<html>

<head>

<script>
pics = new Array()
curPic = 0

preLoad() {
for (i=0; i <= 429; i++) {
pics = new Image()
pics.src = i + ".jpg"
}
}

dispPic() {
document.images['moviePic'].src = curPic + ".jpg"
curPic++
setTimeout("dispPic()", 20)
}
</script>

</head>

<body>

<body onload="preLoad(); dispPic()">

<img src="1.jpg" name="moviePic" width="640" height="416">

</body>

</html>


Functions are declared with the word "function"
Preloading should be done BEFORE the onload=""
20 ms could be to short for some systems

[declare script type]
[use the preloaded entity]
[declare curPic with a var.]
[No double <body>]
[declare "px" in sizes]


<html>
<head>
<script type="text/javascript">
var pics = new Array()
var curPic = 0

for (i=0; i <= 429; i++) {
pics = new Image()
pics.src = i + ".jpg"
}

function dispPic() {
document.images['moviePic'].src = pics[curPic++].src
setTimeout("dispPic()", 20)
}
</script>
</head>
<body onload="dispPic()">
<img src="1.jpg" name="moviePic" width="640px" height="416px">
</body>
</html>

not tested, btw.
 
I

Ivo

[declare "px" in sizes]
<img src="1.jpg" name="moviePic" width="640px" height="416px">

First time I 've seen units declared in simple width and height attributes.
Are you not confused with widths and heights coming from css? But I tried
and found it works (tested in IE6)!
How far backward compatible is this? I 'm sure this wasn't necessary before.
Ivo
 
M

Michael Winter

[declare "px" in sizes]
<img src="1.jpg" name="moviePic" width="640px" height="416px">

First time I 've seen units declared in simple width and height
attributes.
Are you not confused with widths and heights coming from css? But I
tried and found it works (tested in IE6)!
How far backward compatible is this? I 'm sure this wasn't necessary
before.

You are correct: it wasn't and isn't necessary. In fact, I believe it's
erroneous.

The width and height attributes for the IMG element are of type "Length".
Length may either be a "Pixel" value or a percentage. Therefore,
width="640" is automatically stating 640 pixels. No units are necessary,
and are probably incorrect if used.

Mike
 
M

Mick White

Evertjan. said:
function dispPic() {
document.images['moviePic'].src = pics[curPic++].src
setTimeout("dispPic()", 20)
}
</script>
</head>

What happens when you reach 429?
Mick
 
L

Lasse Reichstein Nielsen

Michael Daly said:
....
HTML and its variants specify that "px" is a legitimate qualifier;
why should it be incorrect to use it?

No it doesn't.
<URL:http://www.w3.org/TR/html4/types.html#h-6.6>
The valid values of an HTML length is either pixels (a plain number) or
percentages (a number with "%" after).

Units like "px" are CSS, not HTML. You can use them in they style tag,
but that is CSS content. It should not be used in the width property
(but one should use CSS instead of the width property in any case -
it's even deprecated on HR, TD, TH, and PRE elements).

/L
 
T

Thomas 'PointedEars' Lahn

Ivo said:
[declare "px" in sizes]
<img src="1.jpg" name="moviePic" width="640px" height="416px">

First time I 've seen units declared in simple width and height attributes.
Are you not confused with widths and heights coming from css? But I tried
and found it works (tested in IE6)!

That's one of the Bad Things about IE for developers:
It turns every sh*t into gold.
How far backward compatible is this?
I 'm sure this wasn't necessary before.

It is worng, simple as that.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top