R
Richard A. DeVenezia
At line
this.timerId = setInterval (function(){this.step()}, 100)
I get error dialog
Error:Object doesn't support this property or method.
If I change it to
this.timerId = setInterval (function(){this==window}, 100)
I see true, the sad fact that 'this' is window and not an anim.
What are some proper ways ?
I would like to avoid
this.timerId = setInterval ("Anim.step ( ' "+ this.o.id + " ' ) ", 100)
and avoiding the need for a global hash array (Anim.anims) to keep tracking
of my anims (key:td id, value:anim instance) that would have to be looked up
during each step.
--------
function X (s,cp) {
// cp - cell id prefix
document.write (
'<P>' + s + '</P>'
+'<TABLE BORDER="1">'
+ '<TR>'
+ '<TD ID="cell_1"'
+ ' onMouseOver="X.over(this)"'
+ ' onMouseOut="X.out(this)"'
+ '>this cell gets handled</TD>'
+ '<TD ID="cell_2"'
+ ' onMouseOver="X.over(this)"'
+ ' onMouseOut="X.out(this)"'
+ '>me too</TD>'
+ '</TR></TABLE>'
)
}
function X.over (o) { o.style.background='Black' }
function X.out (o) {
o.anim = new Anim(o);
o.anim.start();
}
var Anim = function (o)
{
this.o = o
this.count=0
}
Anim.prototype.start = function ()
{
this.step();
this.timerId = setInterval (function(){this.step()}, 100)
}
Anim.prototype.step = function ()
{
this.count += 4
if (this.count > 15)
this.stop()
else {
level = anim.count * 16 - 1
anim.o.style.background = 'rgb('+level+','+level+','+level+')'
}
}
Anim.prototype.stop = function ()
{
clearTimeout (this.timerId)
}
-----
this.timerId = setInterval (function(){this.step()}, 100)
I get error dialog
Error:Object doesn't support this property or method.
If I change it to
this.timerId = setInterval (function(){this==window}, 100)
I see true, the sad fact that 'this' is window and not an anim.
What are some proper ways ?
I would like to avoid
this.timerId = setInterval ("Anim.step ( ' "+ this.o.id + " ' ) ", 100)
and avoiding the need for a global hash array (Anim.anims) to keep tracking
of my anims (key:td id, value:anim instance) that would have to be looked up
during each step.
--------
function X (s,cp) {
// cp - cell id prefix
document.write (
'<P>' + s + '</P>'
+'<TABLE BORDER="1">'
+ '<TR>'
+ '<TD ID="cell_1"'
+ ' onMouseOver="X.over(this)"'
+ ' onMouseOut="X.out(this)"'
+ '>this cell gets handled</TD>'
+ '<TD ID="cell_2"'
+ ' onMouseOver="X.over(this)"'
+ ' onMouseOut="X.out(this)"'
+ '>me too</TD>'
+ '</TR></TABLE>'
)
}
function X.over (o) { o.style.background='Black' }
function X.out (o) {
o.anim = new Anim(o);
o.anim.start();
}
var Anim = function (o)
{
this.o = o
this.count=0
}
Anim.prototype.start = function ()
{
this.step();
this.timerId = setInterval (function(){this.step()}, 100)
}
Anim.prototype.step = function ()
{
this.count += 4
if (this.count > 15)
this.stop()
else {
level = anim.count * 16 - 1
anim.o.style.background = 'rgb('+level+','+level+','+level+')'
}
}
Anim.prototype.stop = function ()
{
clearTimeout (this.timerId)
}
-----