# setInterval and class variables

**URL:** <https://forum.kirupa.com/t/setinterval-and-class-variables/188459>\
**Category:** flash\
**Created:** [May 8, 2006, 5:40am UTC](https://forum.kirupa.com/t/setinterval-and-class-variables/188459 "2006-05-08T05:40:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandeep\_cdac200](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sandeep\_cdac200](https://forum.kirupa.com/u/sandeep_cdac200)\
**Post date:** [May 8, 2006, 5:40am UTC](https://forum.kirupa.com/t/setinterval-and-class-variables/188459/1 "2006-05-08T05:40:18Z")

</div>

hi all

very recently i got to work on this thing. The behaviour is weird. if I call setInterval function from my class method it wont give me the class variables.  
but when i call that function individually it works ok.

here is the code.

function fnMain()  
{  
this.\_nIndex=0;  
this.\_nInterval=null;  
}  
fnMain.prototype.callBack=function()  
{  
this.\_nInterval=setInterval(this.fnFrog,200);  
}  
fnMain.prototype.fnFrog=function()  
{  
trace(“index=”+this.\_nIndex);  
}  
var a=new fnMain();  
//—when call this it traces undefined----\  
a.callBack();  
//—when calling this it traces \_nIndex=0–\  
[//a.fnFrog](https://a.fnFrog)();

i think someone will also face this problem in past and he/she can correct me where i was wrong. Thanx for ur replies.
