arcticPigs release V1.0 help files |
Example: The Movie Player script (2) |
The OnSliderDrag function reads the position of the slider button, relative to the translate constraint that is applied to the button, and changes the frame value of the script accordingly. To correctly scale the value, the total length of the choreography is needed. This parameter can be obtained from the chorFile object we initialised when we loaded the chor in the OnCreate handler.
The OnUpdateSlider function is called on a regular interval through the creation of a timer object within the browser. This function ensures the position of the slider button reflects the location within the movie. The last three functions are used to initialise the timer and to stop the timer while the slider is being dragged by the user.
<SCRIPT LANGUAGE=javascript>
function SetMode(newMode)
{
switch(newMode)
{
case(mPlay):
hPlayLight.ambient = 0.9;
hPauseLight.ambient = 0;
hMain.start();
break;
case(mPause):
hPlayLight.ambient = 0;
hPauseLight.ambient = 0.9;
hMain.pause();
break;
default:
hPlayLight.ambient = 0;
hPauseLight.ambient = 0;
hMain.stop();
}
mode = newMode;
}
function OnSliderDrag()
{
if(!bLocChange) StartLocationChange();
hMain.frame = hChor.length * hSlider.base.TLimitRatio.x;
}
function OnUpdateSlider()
{
hSlider.base.TLimitRatio.x = hMain.frame / hChor.length;
if(movieplayer.window.renderQuality < 1.5) {
movieplayer.window.autoRenderQuality = false;
movieplayer.window.renderQuality = 1.5;
}
}
function StartLocationChange()
{
storedmode = mode;
window.clearInterval(htSlider);
bLocChange = true;
SetMode(mPause);
}
function EndLocationChange()
{
SetMode(storedmode);
bLocChange = false;
StartSliderTimer();
}
function StartSliderTimer()
{
if(bMPTimerReady && bMainTimerReady) {
htSlider = window.setInterval(OnUpdateSlider, 100);
}
}
</SCRIPT>
Last Updated: 07/01/02 |