Connecting Tech Pros Worldwide Help | Site Map

Can Somebody Check This?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 10:41 AM
chris
Guest
 
Posts: n/a
Default Can Somebody Check This?

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, 10:41 AM
Evertjan.
Guest
 
Posts: n/a
Default 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, 10:41 AM
Ivo
Guest
 
Posts: n/a
Default 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, 10:42 AM
Michael Winter
Guest
 
Posts: n/a
Default 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, 10:42 AM
Mick White
Guest
 
Posts: n/a
Default 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, 10:42 AM
Michael Daly
Guest
 
Posts: n/a
Default 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, 10:42 AM
Lasse Reichstein Nielsen
Guest
 
Posts: n/a
Default 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, 10:42 AM
Michael Daly
Guest
 
Posts: n/a
Default 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, 11:11 AM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.