start   previous   next

Shout3D™ 2.0 - Workflow Tutorial

Coding the toggle

The logic behind our Start-Stop toggle mechanism is simple. When we click on a label that reads Start-Stop, we want the applet to behave as follow:

Assume that the reference to our TimeSensor is named myTimer, and that there is a variable named started that is initially set to false. In either Java or JavaScript, this logic would be coded like this:


if (started == false) {

    myTimer.start();
    started = true;
}
else if (myTimer.isPaused() == false) {

    myTimer.setPaused(true);
}
else {myTimer.setPaused(false);}

The isPaused() method returns a true value if the TimeSensor is paused, and a false value if it's not. setPaused(true) pauses the TimeSensor and setPaused(false) unpauses it.

Next>


Copyright� 1999-2000, Eyematic Interfaces, Inc.