Actionscript Code:
/////////////////////////////////////////////////////
// CONTROLS
/////////////////////////////////////////////////////
var playState; // 0 - PAUSED , 1 - PLAYING
playbutton.onRelease = function() {
pauseIt();
}
pausebutton.onRelease = function() {
pauseIt();
}
rewindButton.onRelease = function() {
ns.seek(0);
}
var kbord= new Object();
Key.addListener(kbord);
kbord.onKeyDown = function() {
if (Key.isDown(Key.SPACE))
{
pauseIt();
}
}
function pauseIt() {
ns.pause();
switch(playState)
{
case 0:
_root.pausebutton._visible = true ;
_root.playbutton._visible = false ;
playState = 1;
break;
case 1:
_root.pausebutton._visible = false ;
_root.playbutton._visible = true ;
playState = 0;
break;
}
}
function stopIt() {
ns.seek(0);
ns.pause();
}
function restartIt() {
ns.seek(0);
}
/////////////////////////////////////////////////////
// TRACKING
/////////////////////////////////////////////////////
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;
var durationStop:Number;
ns["onMetaData"] = function(obj) {
duration = obj.duration;
durationStop = duration - 0.1; //Redirect movie
};
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 868.0;
loader.scrub._x = ns.time / duration * 868.0;
if(ns.time > durationStop ){
_level1.gotoAndStop("Exterior_Interactive");
exitAndUnload();
}
}
/////////////////////////////////////////////////////
// SCRUBBING
/////////////////////////////////////////////////////
var scrubInterval;
loader.loadbar.onPress = function() {
clearInterval(videoInterval);
loader.scrub._x = loader._xmouse - (loader.scrub._width / 2);
scrubInterval = setInterval(scrubit,10);
loader.scrub.startDrag(false, 0, loader.scrub._y, 868.0, loader.scrub._y);
}
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,868.0,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = loader.loadbar.onRelease = loader.loadbar.onReleaseOutside = function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
loader.scrub.stopDrag();
}
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/868.0)*duration));
}