Click to See Complete Forum and Search --> : Need Help In Automatic Image Update


felicia7
09-01-2003, 01:08 PM
hi i need help in one of my script... it is about automatic image update which is like an animated gif but it is using jpg.
Below is my script... i dunno why my pic can't show up...


<HTML>
<HEAD>
<SCRIPT LANGUAGE = "JavaScript">

timedelay = 1000; //in 1000th of a second
temp = 0;
NumberOfImages = 4;
animation = new Array();

for (i = 0; i < NumberOfImages; i++) {
animation[i] = new Image (640, 480);
animation[i].src = 'anim' + (i + 1) + '.jpg';
}

function AnimateImages()
{
NextImage();
setTimeout("AnimateImages()", timedelay);
}

function NextImage()
{
document.animatedimage.src = animation[temp].src;
temp++;
if(temp >= NumberOfImages) temp = 0;
}

</SCRIPT>
</HEAD>

<BODY>

<TITLE>Automatic Image updater</TITLE>
<TABLE BORDER=0>
<TR><TD>
<FONT SIZE=3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
</TD><TD>
<IMG SRC="anim1.jpg" NAME="animatedimage" WIDTH=640 HEIGHT=480 BORDER=0>
</TD></TR></TABLE>
</BODY>
</HTML>

thanks 4 yr help!!

gil davis
09-01-2003, 01:26 PM
i dunno why my pic can't show up...
I dunno, either. Unless those images are not in the same directory as the HTML file. Do you get a red "X"?

David Harrison
09-01-2003, 02:58 PM
Could you modify this to get what you want?

felicia7
09-02-2003, 03:11 AM
hi thanks... 4 yr help anyway..
i found out how to do my using flash instead... is has the same effect...

cul8er23
09-02-2003, 03:39 AM
This works :
<HTML>
<HEAD>
<SCRIPT LANGUAGE = "JavaScript">

timedelay = 100; //in 1000th of a second
temp = 0;
NumberOfImages = 4;
animation = new Array();

for (i = 0; i < NumberOfImages; i++) {
animation[i] = new Image (640, 480);
animation[i].src = 'anim' + (i + 1) + '.jpg';
}

function AnimateImages()
{
setTimeout("AnimateImages()", timedelay);
NextImage();
}

function NextImage()
{
document.animatedimage.src = eval("animation["+(temp)+"].src");
// alert(eval("animation["+(temp)+"].src"));
temp++;
if(temp >= NumberOfImages) temp = 0;
}

// intitial Call
setTimeout("AnimateImages()", timedelay);

</SCRIPT>
</HEAD>

<BODY>

<TITLE>Automatic Image updater</TITLE>
<TABLE BORDER=0>
<TR><TD>
<FONT SIZE=3>

</TD><TD>
<IMG SRC="anim1.jpg" NAME="animatedimage" WIDTH=640 HEIGHT=480 BORDER=0>
</TD></TR></TABLE>
</BODY>
</HTML>