473,378 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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>
Jul 23 '05 #1
8 1065
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[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>


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)
Jul 23 '05 #2
Ivo
"Evertjan." wrote
[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
Jul 23 '05 #3
On Tue, 4 May 2004 13:31:06 +0200, Ivo <no@thank.you> wrote:
"Evertjan." wrote
[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

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
Evertjan. wrote:
function dispPic() {
document.images['moviePic'].src = pics[curPic++].src
setTimeout("dispPic()", 20)
}
</script>
</head>


What happens when you reach 429?
Mick

Jul 23 '05 #5
On 4-May-2004, Michael Winter <M.******@blueyonder.co.invalid> wrote:
width="640" is automatically stating 640 pixels. No units are necessary,
and are probably incorrect if used.


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
Jul 23 '05 #6
"Michael Daly" <mi*********@foo.bar> writes:
On 4-May-2004, Michael Winter <M.******@blueyonder.co.invalid> wrote:
width="640" is automatically stating 640 pixels. No units are necessary,
and are probably incorrect if used.

.... 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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
On 4-May-2004, wrote:
Units like "px" are CSS, not HTML.


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

Mike
Jul 23 '05 #8
Ivo wrote:
"Evertjan." wrote
[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
Jul 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: martijn | last post by:
Hi There, my vb app can open files. Well, actually my vb app launches word or excell to open them. These files are shared in a network. If somebody else has allready opened that file, you...
6
by: lostinspace | last post by:
After four+ years of using FrontPage in a limited capacity and having created over 600 pages on my sites, I've finally (at least for the most part) abandoned FP, to begin the process of converting...
6
by: Luigi | last post by:
Another bug in IE 6 win. The posted page shows the error. They are four: 1) on the top edge, the upper margin of the container is not added with the body's padding. Instead it seems the two...
7
by: Adam Short | last post by:
I'm having all sorts of problems with Sessions, I've been using them for years with out a hitch, all of a sudden the last 6 - 12 months since getting our new Win2003 server it's all gone shakey!!!...
5
by: Jeremy | last post by:
I have an access db in which a for based on a simple query is updated by the user. It has been being used for a year that way...now it suddenly does not allow an update. The symptom has specific...
4
by: SW1 | last post by:
Well, i think realloc should always work if you just make the buffersize smaller, and thats all I'm doing, if you look at it closely realloc can't ever make the memory bigger in my code (the IF...
5
by: roopeman | last post by:
i want Console write the EventLog message when the source = "Print", code as following : using System; using System.Data; using System.Diagnostics; using System.Text.RegularExpressions;...
5
by: NewToCPP | last post by:
There are several occations where we write onto someone else' memory region. Is there any debugging mechanism to find out which part of the code is causing this problem?
1
by: UJ | last post by:
Can somebody point me to where no touch deployment is really explained? One of the big questions I have is it seems like with no-touch you don't actually have the executable on your machine -...
9
by: ahilar12 | last post by:
1. <head> 2. <script type="text/javascript"> 3. </script> 4. </head> 5. <body> 6. <form> 7. <select name="team" id="mylist" > 8. <option></option> 9....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.