W
wmschneider
I am trying to make a progress animation so that the user knows that
there files are correctly being checked in. Trying to animate papers
moving from the computer to the server pics. I'm brand new at this
language, however, I've been programming in C++ for awhile. This is my
code for that part of it. And I call the startAnimation() function
when the button finish is clicked on. Represented like: <INPUT
TYPE="SUBMIT" NAME="SUBMIT" onclick ="startAnimation()" VALUE="Finish">
<STYLE><!--
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
function startAnimation(){
anim1 = new animation("paper");
anim1.slideBy(320,2, 99, 50);
}
function animation(id) {
this.element = (NS4) ? document[id] : document.all[id].style;
this.active = 0;
this.timer = null;
this.path = null;
this.num = null;
this.name = id + "Var";
eval(this.name + " = this");
this.animate = animate;
this.step = step;
this.show = show;
this.hide = hide;
this.left = left;
this.top = top;
this.moveTo = moveTo;
this.slideBy = slideBy;
this.slideTo = slideTo;
}
function left() {
return parseInt(this.element.left);
}
function top() {
return parseInt(this.element.top);
}
function left() {
return (NS4) ? this.element.left : this.element.pixelLeft;
}
function top() {
return (NS4) ? this.element.top : this.element.pixelTop;
}
function show() {
this.element.visibility = (NS4) ? "show" : "visible";
}
function hide() {
this.element.visibility = (NS4) ? "hide" : "hidden";
}
function moveTo(x, y) {
this.element.left = x;
this.element.top = y;
}
function slideTo(tx, ty, steps, interval) {
var fx = this.left();
var fy = this.top();
var dx = tx - fx;
var dy = ty - fy;
var sx = dx / steps;
var sy = dy / steps;
var ar = new Array();
for (var i = 0; i < steps; i++) {
fx += sx;
fy += sy;
ar = new pos(fx, fy);
}
this.path = ar;
this.animate(interval);
}
function pos(x, y) {
this.x = Math.round(x);
this.y = Math.round(y);
}
function slideBy(dx, dy, steps, interval) {
var fx = this.left();
var fy = this.top();
var tx = fx + dx;
var ty = fy + dy;
this.slideTo(tx, ty, steps, interval);
}
function animate(interval) {
if (this.active) return;
this.num = 0;
this.active = 1;
this.timer = setInterval(this.name + ".step()", interval);
}
function step() {
this.moveTo(this.path[this.num].x, this.path[this.num].y);
if (this.num >= this.path.length - 1) {
clearInterval(this.timer);
this.active = 0;
if (this.statement)
eval(this.statement);
} else {
this.num++;
}
}
there files are correctly being checked in. Trying to animate papers
moving from the computer to the server pics. I'm brand new at this
language, however, I've been programming in C++ for awhile. This is my
code for that part of it. And I call the startAnimation() function
when the button finish is clicked on. Represented like: <INPUT
TYPE="SUBMIT" NAME="SUBMIT" onclick ="startAnimation()" VALUE="Finish">
<STYLE><!--
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
function startAnimation(){
anim1 = new animation("paper");
anim1.slideBy(320,2, 99, 50);
}
function animation(id) {
this.element = (NS4) ? document[id] : document.all[id].style;
this.active = 0;
this.timer = null;
this.path = null;
this.num = null;
this.name = id + "Var";
eval(this.name + " = this");
this.animate = animate;
this.step = step;
this.show = show;
this.hide = hide;
this.left = left;
this.top = top;
this.moveTo = moveTo;
this.slideBy = slideBy;
this.slideTo = slideTo;
}
function left() {
return parseInt(this.element.left);
}
function top() {
return parseInt(this.element.top);
}
function left() {
return (NS4) ? this.element.left : this.element.pixelLeft;
}
function top() {
return (NS4) ? this.element.top : this.element.pixelTop;
}
function show() {
this.element.visibility = (NS4) ? "show" : "visible";
}
function hide() {
this.element.visibility = (NS4) ? "hide" : "hidden";
}
function moveTo(x, y) {
this.element.left = x;
this.element.top = y;
}
function slideTo(tx, ty, steps, interval) {
var fx = this.left();
var fy = this.top();
var dx = tx - fx;
var dy = ty - fy;
var sx = dx / steps;
var sy = dy / steps;
var ar = new Array();
for (var i = 0; i < steps; i++) {
fx += sx;
fy += sy;
ar = new pos(fx, fy);
}
this.path = ar;
this.animate(interval);
}
function pos(x, y) {
this.x = Math.round(x);
this.y = Math.round(y);
}
function slideBy(dx, dy, steps, interval) {
var fx = this.left();
var fy = this.top();
var tx = fx + dx;
var ty = fy + dy;
this.slideTo(tx, ty, steps, interval);
}
function animate(interval) {
if (this.active) return;
this.num = 0;
this.active = 1;
this.timer = setInterval(this.name + ".step()", interval);
}
function step() {
this.moveTo(this.path[this.num].x, this.path[this.num].y);
if (this.num >= this.path.length - 1) {
clearInterval(this.timer);
this.active = 0;
if (this.statement)
eval(this.statement);
} else {
this.num++;
}
}