all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

setInterval inside Class methods


Re: setInterval inside Class methods DMennenoh **AdobeCommunityExpert**
10/31/2006 2:35:08 PM
flash actionscript:
Or...

setInterval(testInt, 500, this);

function testInt(classRef:Test){
trace(classRef.testVar);
}

--
Dave -
Head Developer
www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

setInterval inside Class methods ogre11
10/31/2006 6:35:49 PM
if I call setInterval from a method and set it to run another method outside
the calling method, it can't read instance variables, but doesn't give me the
error that there is no such variable, just returns undefined. Example:

class Test{
var testVar:String = 'test';

public function Test(){
setInterval(testInt, 500);
}

public function testInt():Void{
trace(testVar); // returns undefined
}
}

but

class Test{
var testVar:String = 'test';

public function Test(){
setInterval(testInt, 500);


function testInt():Void{
trace(testVar); // returns test
}
}

}

not so much an error as peculiarity, took me a while to catch on, though.
Re: setInterval inside Class methods LuigiL
10/31/2006 6:55:55 PM
The synatx for setInterval is different in classes. The function should be:
public function Test(){
setInterval(this,"testInt", 500);
Re: setInterval inside Class methods ogre11
10/31/2006 6:57:48 PM
AddThis Social Bookmark Button