Hello,
The objects I've created r fairly big so I hope the following
represents the problem ok.
I've got a custom object as follows:
*******************************************
//filename is myscript.js
function ChangeCount(count)
{
this.count += 1;
setTimeout("ChangeCount(this.count);", 100);
}
function Obj()
{
this.count = 1;
this.ChangeCount = ChangeCount;
}
//global var
ObjHolder;
function SetUp()
{
ObjHolder = new Obj;
}
*******************************************
<script src="myscript.js"></script>
<body onLoad="SetUp();">
<img onClick="ObjHolder.ChangeCount(2);" />
*******************************************
The problem is that when the setTimeout fires it calls the
ChangeCount function as expected but the variable this.count
is now invalid because it is not of the same object instance
as the ObjHolder variable.
Help please!!!!!!
The objects I've created r fairly big so I hope the following
represents the problem ok.
I've got a custom object as follows:
*******************************************
//filename is myscript.js
function ChangeCount(count)
{
this.count += 1;
setTimeout("ChangeCount(this.count);", 100);
}
function Obj()
{
this.count = 1;
this.ChangeCount = ChangeCount;
}
//global var
ObjHolder;
function SetUp()
{
ObjHolder = new Obj;
}
*******************************************
<script src="myscript.js"></script>
<body onLoad="SetUp();">
<img onClick="ObjHolder.ChangeCount(2);" />
*******************************************
The problem is that when the setTimeout fires it calls the
ChangeCount function as expected but the variable this.count
is now invalid because it is not of the same object instance
as the ObjHolder variable.
Help please!!!!!!
Comment