MovieLoop.js
Summary
No overview generated for 'MovieLoop.js'
mapbuilder.loadScript(baseDir+"/tool/ToolBase.js");
function MovieLoop(toolNode, model) {
ToolBase.apply(this, new Array(toolNode, model));
this.frameIncrement = 1;
this.model.setParam("firstFrame", 0);
this.timestampIndex = 0;
window.movieLoop = this;
this.isRunning = false;
this.frameIsLoading = false;
this.delay = 1000/this.getProperty("mb:framesPerSecond", 10);
this.maxFrames = this.getProperty("mb:maxFrames", 30);
this.setFrame = function(index) {
var timestampList = this.model.timestampList;
var ts;
if (this.timestampIndex!=null) {
var ts = timestampList.childNodes[this.timestampIndex];
if (ts) {
ts.setAttribute("current", "0");
this.model.setParam("timestamp", this.timestampIndex);
}
}
var firstFrame = this.model.getParam("firstFrame");
var lastFrame = this.model.getParam("lastFrame");
if (index > lastFrame) index = firstFrame;
if (index < firstFrame) index = lastFrame;
this.timestampIndex = index;
ts = timestampList.childNodes[this.timestampIndex];
ts.setAttribute("current", "1");
this.model.setParam("timestamp", this.timestampIndex);
}
this.nextFrame = function(step) {
var objRef = window.movieLoop;
var increment = objRef.frameIncrement;
if (step) increment = step; //arg passed in overrides default
if (!this.frameIsLoading) {
objRef.setFrame(objRef.timestampIndex + increment);
}
}
this.setFrameLimits = function(objRef) {
var timestampList = objRef.model.timestampList;
var firstFrame = objRef.model.getParam("firstFrame");
var lastFrame = firstFrame+objRef.maxFrames;
if (lastFrame > timestampList.childNodes.length) lastFrame = timestampList.childNodes.length-1;
objRef.model.setParam("lastFrame",lastFrame);
timestampList.childNodes[firstFrame].setAttribute("current","1");
}
this.model.addFirstListener("refresh",this.setFrameLimits,this);
this.model.addListener("firstFrame",this.setFrameLimits,this);
this.reset = function(objRef) {
objRef.pause();
objRef.setFrame(objRef.model.getParam("firstFrame"));
}
this.model.addListener("loadModel",this.reset,this);
this.init = function(objRef) {
if (!objRef.initialized) {
objRef.initialized = true;
objRef.reset(objRef);
}
}
this.model.addListener("bbox", this.init, this);
this.uninit = function(objRef) {
objRef.initialized = false;
}
this.model.addListener("newModel", this.uninit, this);
this.play = function() {
if (!this.isRunning) {
this.movieTimer = setInterval('window.movieLoop.nextFrame()',this.delay);
this.isRunning = true;
}
}
this.pause = function() {
this.isRunning = false;
clearInterval(this.movieTimer);
}
this.stop = function() {
this.pause();
this.reset(this);
}
this.stopListener = function(objRef) {
objRef.stop();
}
this.model.addListener("stopLoop",this.stopListener,this);
}
Documentation generated by
JSDoc on Sun Apr 27 20:30:54 2008