Below all the helper functions are defined. SetMode changes the ambient values of the 3D play and pause buttons. This causes them to light up when clicked. The next page shows how the SetMode function gets coupled to the onClick event of the various groups to make this work.

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>


 

©2000 arcticpigs. All rights reserved.
This is a draft version! The functionality of parts of the software are liable to change.