PDA

View Full Version : slideshow


Kevin
02-01-2003, 05:27 AM
Put together a slide show with an auto and manual setup.
Everything looks o.k. but I have several object not supported errors. Can you advise?

insight always appreciated

Thank You;)
Kevin

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0062)http://voyager.deanza.fhda.edu/~philun/JSExamples/images1.html -->
<HTML><HEAD><TITLE>Phlowers</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT language=JavaScript type=text/javascript>
<!--
var MyPics = new Array()
if (document.images) {
MyPics[0] = new Image(288,288) // pre-cache slide images
MyPics[1] = new Image(288,288)
MyPics[2] = new Image(288,288)
MyPics[3] = new Image(288,288)
MyPics[4] = new Image(288,288)
MyPics[5] = new Image(288,288)

MyPics[0].src = "flower01.gif"
MyPics[1].src = "flower02.gif"
MyPics[2].src = "flower03.gif"
MyPics[3].src = "flower04.gif"
MyPics[4].src = "flower05.gif"
MyPics[5].src = "flower06.gif"
}

var IndexSlide = 0;
var LastSlide = MyPics.length - 1;
var Manual = 1;
var AutoTimer = 0;

function RandSlide()
{
var NxtSlide = Math.floor(Math.Random() * 6 );
document.Pix.src = MyPics[NxtSlide].src;
} /* end RandSlide() */

function Auto()
{
if (AutoTimer)
{
clearTimeout(AutoTimer);
}
AutoTimer = setTimeout (RandSlide(), 1500);

} /* end Auto() */

function Manual()
{
Manual = 1;
if (AutoTimer)
{
clearTimeout (AutoTimer);
} /* if */
} /* end Manual() */

function NextPix()
{
if (manual)
{
IndexSlide++
if (IndexSlide > LastSlide) {
IndexSlide = 0
}
}
document.Pix.src = MyPics[IndexSlide].src
} /* end NextPix() */

function PrevPix ()
{
if (Manual)
{
IndexSlide--
if (IndexSlide < 0) {
IndexSlide = lastSlide
} /* if */
document.Pix.src = MyPics[IndexSlide].src
}
else
{
alert ("Rand Slide show in progress please hit the manual button to end the show.");
} /* if */
} /* end PrevPix() */
//-->
</SCRIPT>

<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY bgColor=cornsilk>
<DIV align=center>
<P><BR></P>
<H2>Phil's Phlower Photos</H2>
<P><BR></P><IMG height=288 alt=FLOWERS src="flower01.gif" width=288 name=Pix>
<FORM name=SlideShow>
<INPUT onclick=PreviousPix() type=button value=" << ">
<img src="spacer.gif" width="50" height="5" alt="" border="0">
<INPUT onclick=NextPix() type=button value=" >> "><br />

Please choose either the manual button or the auto button for browsing thru the slides.<br />

<input type="button" name="Manual" value=" manual " onClick="Manual()">
<img src="spacer.gif" width="50" height="5" alt="" border="0">
<INPUT type=button onClick="Auto()" value=" auto ">
</FORM>
</DIV>
</BODY>
</HTML>

BrightNail
02-01-2003, 07:47 AM
hhmm,

well...this var is undefined

if (manual)

I looked thru your code and other than above, you are making no reference to it! .....I think mean for it to be a capital 'M'

Kevin
02-01-2003, 11:53 PM
Still working away here. Can you take another look and see if you can spot any other errors? I found a couple more and cleaned them up but still ...

I have an object not supported for the previousPix() function. line 91

The slide show shows auto button starts the slide show and shows one image, then it stops. NO errors reported.

The manual button also throws an error stating object dosen't support this property on line 96.
The only thing manual does is set the value of var manual to 1 and clear the timeout if it exists.

if you can advise I would appreciated it

Thank You
Kevin Raleigh
http://voyager.deanza.fhda.edu/~kkr42797/slideShow.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0062)http://voyager.deanza.fhda.edu/~philun/JSExamples/images1.html -->
<HTML><HEAD><TITLE>Phlowers</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT language=JavaScript type=text/javascript>
<!--
var MyPics = new Array()
if (document.images) {
MyPics[0] = new Image(288,288) // pre-cache slide images
MyPics[1] = new Image(288,288)
MyPics[2] = new Image(288,288)
MyPics[3] = new Image(288,288)
MyPics[4] = new Image(288,288)
MyPics[5] = new Image(288,288)

MyPics[0].src = "flower01.gif"
MyPics[1].src = "flower02.gif"
MyPics[2].src = "flower03.gif"
MyPics[3].src = "flower04.gif"
MyPics[4].src = "flower05.gif"
MyPics[5].src = "flower06.gif"
}

var IndexSlide = 0;
var LastSlide = MyPics.length - 1;
var Manual = 1;
var AutoTimer = 0;

function RandSlide()
{
var NxtSlide = Math.floor(Math.random() * 6 );
document.Pix.src = MyPics[NxtSlide].src;
} /* end RandSlide() */

function Auto()
{
Manual = 0;
if (AutoTimer)
{
clearTimeout(AutoTimer);
}
AutoTimer = setTimeout ("RandSlide()",100);

} /* end Auto() */

function Manual()
{
Manual = 1;
if (AutoTimer)
{
clearTimeout (AutoTimer);
} /* if */
} /* end Manual() */

function NextPix()
{
if (Manual)
{
IndexSlide++
if (IndexSlide > LastSlide) {
IndexSlide = 0
}
}
document.Pix.src = MyPics[IndexSlide].src
} /* end NextPix() */

function PrevPix ()
{
if (Manual)
{
IndexSlide--
if (IndexSlide < 0) {
IndexSlide = lastSlide
} /* if */
document.Pix.src = MyPics[IndexSlide].src
}
else
{
alert ("Rand Slide show in progress please hit the manual button to end the show.");
} /* if */
} /* end PrevPix() */
//-->
</SCRIPT>

<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY bgColor=cornsilk>
<DIV align=center>
<P><BR></P>
<H2>Phil's Phlower Photos</H2>
<P><BR></P><IMG height=288 alt=FLOWERS src="flower01.gif" width=288 name=Pix>
<FORM name=SlideShow>
<INPUT onclick=PreviousPix() type="button" value=" << "><img src="spacer.gif" width="50" height="5" alt="" border="0">
<INPUT onclick=NextPix() type="button" value=" >> "><br />

Please choose either the manual button or the auto button for browsing thru the slides.<br />

<input type="button" name="Manual" value=" manual " onclick=Manual()><img src="spacer.gif" width="50" height="5" alt="" border="0">
<INPUT type="button" onclick=Auto() value=" auto ">
</FORM>
</DIV>
</BODY>
</HTML>

RoyW
02-02-2003, 12:40 AM
var Manual = 1;

function Manual()

In most languages this is allowed, not in javascript. try

var IsManual = 1;

(but you should really use
IsManual = true;
)

also

name="Manual" could cause problems.

Javascript has a single namespace for functions and variables.