The Fader Applet has an API so that you can controle the applet from
within other Java Applets or from JavaScript (here is an example)!
As I expect authors of Java Applets to know how to use it, I will only
explain here how to controle the Fader Applet from JavaScript.
The <Applet> Tag
First of all, you need to include the applet in an
html file, where you should not forget to specify a name
in the applet tag, e.g. <applet name="Fader"
...>.
To have the complete controle over the applet's behaviour, you should
use the parameter: <param name = "mode" value = "onCall">.
The applet then displays the first image, but does not start fading;
it waits for function calls.
Calling Functions from the Applet's API
Now you can use Java or JavaScript to call functions from the applet's
API.
Example 1: Using Buttons
The following code sequence implements a button that enables the
user to fade stepwise through the images (cf. the example).
<form name="nextFaderImage">
<input type=button value=" next image "
onclick="document.Fader.gotoNextImage()">
</form>
Example 2: More than one Applet
You can use JavaScript to fade between images that are in different
parts of your page (cf. example) using the
setTimeout() JavaScript function.
E.g., the fading between the three images in the example is done by:
runRoundTrip = 1;
function startRoundTrip() {
runRoundTrip = 1;
document.Fader1.gotoNextImage();
setTimeout("roundTrip2()",4000);
}
function stopRoundTrip() {
runRoundTrip = 0;
}
function roundTrip1() {
document.Fader3.gotoNextImage();
document.Fader1.gotoNextImage();
if(runRoundTrip == 1) { setTimeout("roundTrip2()",4000); }
}
function roundTrip2() {
document.Fader1.gotoNextImage();
document.Fader2.gotoNextImage();
if(runRoundTrip == 1) { setTimeout("roundTrip3()",4000); }
}
function roundTrip3() {
document.Fader2.gotoNextImage();
document.Fader3.gotoNextImage();
if(runRoundTrip == 1) { setTimeout("roundTrip1()",4000); }
}
The API
There are many functions to controle the behaviour of the
applet, but you might feel that some feature is missing.
In this case, just contact
me via e-mail.
- public void gotoNextImage()
Fades to the next image.
- public boolean setMode(String newMode)
Tries to set the mode (cf. in html code for a
list of possible modes).
- public boolean setEndPause(int newEndPause)
Set the endPause value (cf. in html code).
- public boolean setStepWidth(int newStepWidth)
Set the stepWidth value (cf. in html code).
- public void stop()
Stops the fading process.
- public void start()
Starts the fading process.
- public String getAppletInfo()
Gives a short information on the applet: version, copyright.
........................... ...... ......
home |
API |
in html code