473,322 Members | 1,431 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,322 software developers and data experts.

JavaScript animation doesn't work

Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
with one coin (tet) morphing into another. The code doesn't work.
Anybody feel like taking a shot at correcting me? It's short. Here it
is:

<HTML>

<HEAD>
<TITLE>Thracian tetradrachm animation</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- begin script
tetSeries = new Array("tet00.jpg", "tet01.jpg", "tet02.jpg",
"tet03.jpg", "tet04.jpg", "tet05.jpg", "tet06.jpg",

"tet07.jpg", "tet08.jpg", "tet09.jpg");
imagesCache = new Array ()
for (i=0;i<tetSeries.length;i++) {
imagesCache[i] = new Image;
imagesCache[i].src = tetSeries[i]
}
theCount = 0;
function turnPage() {
if(theCount == imagesCache.length-1)
{
theCount = 0
} else {
theCount++
}
document.tet.src = imagesCache[theCount].src;
setTimeout("turnPage()", 300);
// end script -->
</SCRIPT>

</HEAD>

<BODY>

<img name="tet" src="tet00.jpg" width="372" height="365" border="0"
alt="Tet images">

<body bgcolor="#FFFFFF"onload="turnPage()">

</BODY>

</HTML>

Thanks.

--

Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
Glomming: Coin Connoisseurship: http://rg.ancients.info/glom
Bogos: Counterfeit Coins: http://rg.ancients.info/bogos
Jul 20 '05 #1
6 3090
Reid Goldsborough wrote:

Hi reid, You have been sloppy.
Read on, but please note that opening your Javascriptconsole in your own
browser gives you the errors too....

Before you post a JS-question, first check your own JS-console for obvious
errors..
Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
with one coin (tet) morphing into another. The code doesn't work.
Anybody feel like taking a shot at correcting me? It's short. Here it
is:

<HTML>

<HEAD>
<TITLE>Thracian tetradrachm animation</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- begin script
tetSeries = new Array("tet00.jpg", "tet01.jpg", "tet02.jpg",
"tet03.jpg", "tet04.jpg", "tet05.jpg", "tet06.jpg",

"tet07.jpg", "tet08.jpg", "tet09.jpg");
imagesCache = new Array ()
for (i=0;i<tetSeries.length;i++) {
imagesCache[i] = new Image;
imagesCache[i].src = tetSeries[i]
}
theCount = 0;
function turnPage() {
if(theCount == imagesCache.length-1)
{
theCount = 0
} else {
theCount++
}
document.tet.src = imagesCache[theCount].src;
setTimeout("turnPage()", 300);
what about closing your function here??
// end script -->
</SCRIPT>

</HEAD>

<BODY>

<img name="tet" src="tet00.jpg" width="372" height="365" border="0"
alt="Tet images">

<body bgcolor="#FFFFFF"onload="turnPage()">

</BODY>

</HTML>

Thanks.

--

Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
Glomming: Coin Connoisseurship: http://rg.ancients.info/glom
Bogos: Counterfeit Coins: http://rg.ancients.info/bogos


Jul 20 '05 #2
On Thu, 11 Sep 2003 14:50:20 +0200, Erwin Moller
<si******************************************@spam yourself.com> wrote:
Hi reid, You have been sloppy.
Thanks for your kind words.
Read on, but please note that opening your Javascriptconsole in your own
browser gives you the errors too.... Before you post a JS-question, first check your own JS-console for obvious
errors..


I don't have a JS-console or any other console, that I know of. I'm
using Notepad to edit code that was suggested in an article I read. As
I said, I'm a neophyte here. I don't have an interest in learning
JavaScript. I know I should, that this is the "proper" way to go.
Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
with one coin (tet) morphing into another. The code doesn't work.
Anybody feel like taking a shot at correcting me? It's short. Here it
is:

<HTML>

<HEAD>
<TITLE>Thracian tetradrachm animation</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- begin script
tetSeries = new Array("tet00.jpg", "tet01.jpg", "tet02.jpg",
"tet03.jpg", "tet04.jpg", "tet05.jpg", "tet06.jpg",

"tet07.jpg", "tet08.jpg", "tet09.jpg");
imagesCache = new Array ()
for (i=0;i<tetSeries.length;i++) {
imagesCache[i] = new Image;
imagesCache[i].src = tetSeries[i]
}
theCount = 0;
function turnPage() {
if(theCount == imagesCache.length-1)
{
theCount = 0
} else {
theCount++
}
document.tet.src = imagesCache[theCount].src;
setTimeout("turnPage()", 300);


what about closing your function here??


I don't know what this means. And a Google search just now didn't
reveal anything useful as to what exactly this means, how I should
close my function.

--

Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
Glomming: Coin Connoisseurship: http://rg.ancients.info/glom
Bogos: Counterfeit Coins: http://rg.ancients.info/bogos
Jul 20 '05 #3
Reid Goldsborough wrote:
On Thu, 11 Sep 2003 14:50:20 +0200, Erwin Moller
<si******************************************@spam yourself.com> wrote:
Hi reid, You have been sloppy.
Thanks for your kind words.


Hi Reid,

I don't want to insult you but you were sloppy.
:-/
Read on, but please note that opening your Javascriptconsole in your own
browser gives you the errors too....
Before you post a JS-question, first check your own JS-console for obvious
errors..


I don't have a JS-console or any other console, that I know of. I'm
using Notepad to edit code that was suggested in an article I read. As
I said, I'm a neophyte here. I don't have an interest in learning
JavaScript. I know I should, that this is the "proper" way to go.


Okay, go download a browser, IE-explorer, Mozilla, whatever suits your
needs.
Under Mozilla (and Netscape) under Tools-menu --> webdevelopment -->
Javascript Console.

Under IE, you'll have to figure it out yourself, but I am sure they have it
too.

That console is your friend.
Use it always when something happens that you don't understand.
Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
with one coin (tet) morphing into another. The code doesn't work.
Anybody feel like taking a shot at correcting me? It's short. Here it
is:

<HTML>

<HEAD>
<TITLE>Thracian tetradrachm animation</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- begin script
tetSeries = new Array("tet00.jpg", "tet01.jpg", "tet02.jpg",
"tet03.jpg", "tet04.jpg", "tet05.jpg", "tet06.jpg",

"tet07.jpg", "tet08.jpg", "tet09.jpg");
imagesCache = new Array ()
for (i=0;i<tetSeries.length;i++) {
imagesCache[i] = new Image;
imagesCache[i].src = tetSeries[i]
}
theCount = 0;
function turnPage() {
if(theCount == imagesCache.length-1)
{
theCount = 0
} else {
theCount++
}
document.tet.src = imagesCache[theCount].src;
setTimeout("turnPage()", 300);
what about closing your function here??


I don't know what this means. And a Google search just now didn't
reveal anything useful as to what exactly this means, how I should
close my function.


Your function called turnPage is never closed.

It should be like this:
function turnPage(){
// your code
// more code
}

Watch the closing }
So the one after turnPage() { is for opening.
And it should always have a corresponding }

Good luck.

I checked your function, but it works.

Regards,
Erwin

--

Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
Glomming: Coin Connoisseurship: http://rg.ancients.info/glom
Bogos: Counterfeit Coins: http://rg.ancients.info/bogos


Jul 20 '05 #4
On Fri, 12 Sep 2003 10:51:53 +0200, Erwin Moller
<si******************************************@spam yourself.com> wrote:
I don't want to insult you but you were sloppy.


OK, I'm sloppy. I think I'm new to this and know very little about it
and tried to carefully follow the directions in this magazine article
I read, but if you say I'm sloppy, I have no problem with this.

Here's a question that you, being an expert and not sloppy, may know
the answer to. How do I place this JavaScript code within a page
rather than, as I did, have a new page for it? Here's the code again,
this time with the function closed as you suggested before, which made
it work:

<HTML>
<HEAD>
<META NAME="Author" Content="Reid Goldsborough">
<TITLE>Thracian tetradrachm animation</TITLE>
<SCRIPT LANGUAGE="JavaScript">
tetSeries = new Array("tet00.jpg", "tet01.jpg", "tet02.jpg",
"tet03.jpg", "tet04.jpg", "tet05.jpg", "tet06.jpg", "tet07.jpg",
"tet08.jpg", "tet09.jpg", "tet09.jpg", "tet09.jpg");
imagesCache = new Array ()
for (i=0;i<tetSeries.length;i++) {
imagesCache[i] = new Image;
imagesCache[i].src = tetSeries[i]
}
theCount = 0;
function turnPage() {
if(theCount == imagesCache.length-1)
{
theCount = 0
} else {
theCount++
}
document.tet.src = imagesCache[theCount].src;
setTimeout("turnPage()", 600);
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF"onload="turnPage()">
<CENTER>
<img name="tet" src="tet00.jpg" width="372" height="365" border="0"
alt="Tet animation">
</CENTER>
</BODY>
</HTML>

I tried placing some of this code into the body of the page but
couldn't get the animation to work.

--

Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
Glomming: Coin Connoisseurship: http://rg.ancients.info/glom
Bogos: Counterfeit Coins: http://rg.ancients.info/bogos
Jul 20 '05 #5
On Sat, 13 Sep 2003 15:25:18 -0400
Reid Goldsborough <re******@netaxs.com> wrote:
<snip>

Hi, Reid. I'm just a newbie on the animation stuff, but your code works
fine on my box with Opera 7.11. The only change I had to make was to
access a set of images here:

tetSeries = new Array("droep0.gif",...

imagesCache[i].src = "../images/droep/" + tetSeries[i];

Are you sure that your images are in the same directory as the html?

--
Don't you see that the whole aim of Newspeak is to narrow the range of
thought? In the end we shall make thoughtcrime literally impossible,
because there will be no words in which to express it.
-- George Orwell, 1984

Jul 20 '05 #6
Reid Goldsborough wrote:
On Fri, 12 Sep 2003 10:51:53 +0200, Erwin Moller
<si******************************************@spam yourself.com> wrote:
I don't want to insult you but you were sloppy.
OK, I'm sloppy. I think I'm new to this and know very little about it
and tried to carefully follow the directions in this magazine article
I read, but if you say I'm sloppy, I have no problem with this.


Hi Reid,

So I did insult you. Sorry man, but relax.

One can make many mistakes in code, ranging from just a typo in a
variablename to a very subtle fault in some recursive function.

Not closing a function is just sloppy. I am not saying you are sloppy or
your are not smart, I just say the code you send was sloppy. Do not take
that personally.
Example: My english is sloppy, I know that. It is not my mothertongue. If
somebody corrects me and says I am sloppy, I just take that as an
informative correction, not personal.

Back to the subject, allright?
Here's a question that you, being an expert and not sloppy, may know
the answer to.
Give it a rest now, Reid. ;-)

How do I place this JavaScript code within a page
rather than, as I did, have a new page for it? Here's the code again,
this time with the function closed as you suggested before, which made
it work:
Ok.
So your code works on this (example)page?
Then it will work in another page too.
Just be sure that:
1) Your imagename in the image-tag in your page corresponds with the one you
use in your function.
2) Be sure that the images can be found. It is relative from the the path
where the page resides.

<HTML>
<HEAD>
<META NAME="Author" Content="Reid Goldsborough">
<TITLE>Thracian tetradrachm animation</TITLE>
<SCRIPT LANGUAGE="JavaScript">
tetSeries = new Array("tet00.jpg", "tet01.jpg", "tet02.jpg",
"tet03.jpg", "tet04.jpg", "tet05.jpg", "tet06.jpg", "tet07.jpg",
"tet08.jpg", "tet09.jpg", "tet09.jpg", "tet09.jpg");
imagesCache = new Array ()
for (i=0;i<tetSeries.length;i++) {
imagesCache[i] = new Image;
imagesCache[i].src = tetSeries[i]
}
theCount = 0;
function turnPage() {
if(theCount == imagesCache.length-1)
{
theCount = 0
} else {
theCount++
}
document.tet.src = imagesCache[theCount].src;
setTimeout("turnPage()", 600);
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF"onload="turnPage()">

This is wrong. It should be:
<BODY bgcolor="#FFFFFF" onload="turnPage()">

with a space before the onLoad="turnPage()"
ANd I think it should be onLoad instead of onload, with a capital L.
I am not sure which browsers will forgive it, better try to spell it
correct. :-)

<CENTER>
<img name="tet" src="tet00.jpg" width="372" height="365" border="0"
alt="Tet animation">
</CENTER>
</BODY>
</HTML>

I tried placing some of this code into the body of the page but
couldn't get the animation to work.

Jul 20 '05 #7

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

Similar topics

5
by: Brian Angliss | last post by:
I'm relatively new to scripting in JavaScript, so I'm not too surprised I'm having difficulty scripting up an animation effect for my personal site. What I'm trying to do is the following: When...
2
by: billrdio | last post by:
I am trying to make a JavaScript animation of real-time images - i.e. images that will periodically change on the server. The problem I am having is that the JavaScript animation I have created is...
5
by: wmschneider | last post by:
I am trying to make a progress animation so that the user knows that there files are correctly being checked in. Trying to animate papers moving from the computer to the server pics. I'm brand...
1
by: Scott | last post by:
I have an asp.net page that performs a function for a user that can take up to 30 seconds. So, I have a javascript function that shows an animation to let the user know something is going on. I...
2
by: Chris | last post by:
Hi, I have a Javascript function that loads a page with a progress bar for long process. The progress bar is a gif animation and for some reason it the animation is stuck when the function is...
2
by: rdemyan via AccessMonster.com | last post by:
My application has a lot of complicated SQL statements, calculations, processing that takes time. I've created a custom form to act like a messagebox. It has 10 small rectangles on it that change...
7
by: mdw9604 | last post by:
Hi all, I am newbie at javascript, but I have a script that animates gif images and worked for a number of years, but now with IE7 it does not work. I am getting an error on this line of...
4
by: lilOlMe | last post by:
Hi there! I've run into a bit of a problem wherein a <div> containing an error message is made invisible by an animation. I've tried everything to make this <div> reappear on a button click...
5
Frinavale
by: Frinavale | last post by:
I have a slight problem with a Tab Control that I've developed for an application. Once sent to the browser it runs via JavaScript. The JavaScript is dynamically generated by my .NET code. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.