Connecting Tech Pros Worldwide Help | Site Map

Can Somebody Check This?

  #1  
Old July 23rd, 2005, 11:41 AM
chris
Guest
 
Posts: n/a
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[i] = new Image()
pics[i].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>
  #2  
Old July 23rd, 2005, 11:41 AM
Evertjan.
Guest
 
Posts: n/a

re: Can Somebody Check This?


chris wrote on 03 mei 2004 in comp.lang.javascript:
[color=blue]
> <html>
>
> <head>
>
> <script>
> pics = new Array()
> curPic = 0
>
> preLoad() {
> for (i=0; i <= 429; i++) {
> pics[i] = new Image()
> pics[i].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>[/color]

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[i] = new Image()
pics[i].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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
  #3  
Old July 23rd, 2005, 11:41 AM
Ivo
Guest
 
Posts: n/a

re: Can Somebody Check This?


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

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


  #4  
Old July 23rd, 2005, 11:42 AM
Michael Winter
Guest
 
Posts: n/a

re: Can Somebody Check This?


On Tue, 4 May 2004 13:31:06 +0200, Ivo <no@thank.you> wrote:
[color=blue]
> "Evertjan." wrote
>[color=green]
>> [declare "px" in sizes]
>> <img src="1.jpg" name="moviePic" width="640px" height="416px">[/color]
>
> 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.[/color]

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

--
Michael Winter
M.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
  #5  
Old July 23rd, 2005, 11:42 AM
Mick White
Guest
 
Posts: n/a

re: Can Somebody Check This?


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

What happens when you reach 429?
Mick

  #6  
Old July 23rd, 2005, 11:42 AM
Michael Daly
Guest
 
Posts: n/a

re: Can Somebody Check This?


On 4-May-2004, Michael Winter <M.Winter@blueyonder.co.invalid> wrote:
[color=blue]
> width="640" is automatically stating 640 pixels. No units are necessary,
> and are probably incorrect if used.[/color]

Specifying the default in most languages is rarely incorrect even if unnecessary.
It just helps to make the information very specific. HTML and its variants
specify that "px" is a legitimate qualifier; why should it be incorrect to use it?

Mike
  #7  
Old July 23rd, 2005, 11:42 AM
Lasse Reichstein Nielsen
Guest
 
Posts: n/a

re: Can Somebody Check This?


"Michael Daly" <michaelDaly@foo.bar> writes:
[color=blue]
> On 4-May-2004, Michael Winter <M.Winter@blueyonder.co.invalid> wrote:
>[color=green]
>> width="640" is automatically stating 640 pixels. No units are necessary,
>> and are probably incorrect if used.[/color][/color]

....[color=blue]
> HTML and its variants specify that "px" is a legitimate qualifier;
> why should it be incorrect to use it?[/color]

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
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
  #8  
Old July 23rd, 2005, 11:42 AM
Michael Daly
Guest
 
Posts: n/a

re: Can Somebody Check This?


On 4-May-2004, wrote:
[color=blue]
> Units like "px" are CSS, not HTML.[/color]

You're right - I stand corrected. What a Babel we've got here!

Mike
  #9  
Old July 23rd, 2005, 12:11 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a

re: Can Somebody Check This?


Ivo wrote:
[color=blue]
> "Evertjan." wrote[color=green]
>> [declare "px" in sizes]
>> <img src="1.jpg" name="moviePic" width="640px" height="416px">[/color]
>
> 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)![/color]

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

It is worng, simple as that.


PointedEars
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can somebody please help me finish this i started but can't finish rfreder2 answers 4 October 3rd, 2006 08:43 AM
Can somebody point me to where no touch deployment is really explained. UJ answers 1 July 13th, 2006 09:15 PM
annoying delay during refresh of aspx web page with ODBC Access query on IIS Windows 2003 Wolfgang Kaml answers 10 November 18th, 2005 04:21 AM
annoying delay during refresh of aspx web page with ODBC Access query on IIS Windows 2003 Wolfgang Kaml answers 11 July 19th, 2005 11:25 AM