| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
bonafide braindead
Join Date: Aug 2004
Posts: 25
|
Hello!
I'm trying to get to grips with as2, but I'm having problems with setInterval. Anyone know what I'm doing wrong? Code:
//Class
class Test {
private var intervalID:Number;
function Test() {
loadFile();
}
private function loadFile():Void {
intervalID = setInterval(this, "readTrack", 1000, "foo");
}
private function readTrack(sString:String):Void {
trace(sString);
var myThing:String = "bar";
displayThing(myThing);
}
private function displayThing(vThing:String):Void {
trace(vThing);
}
}
//Code in movie
stop();
function init() {
var thing:Test = new Test();
}
init();
|
|
|
|
|
|
#3 |
|
unRegistered User
|
You have an error in your interval deffinision:
PHP Code:
PHP Code:
|
|
|
|
|
|
#4 |
|
bonafide braindead
Join Date: Aug 2004
Posts: 25
|
ActionScript Code:
Thanks senocular, I think I must be going blind! |
|
|
|
|
|
#5 |
|
bonafide braindead
Join Date: Aug 2004
Posts: 25
|
deQue: actually, that's to provide the readTrack function with scope. Otherwise it can't call the displayThing method.
|
|
|
|
|
|
#6 | |
|
six eyes
|
Quote:
Its actually a very common problem. Whether you meant to make it a local variable or not, its not too intuitive that an interval in such a situation will fizzle as a result of the containing objects destruction in memory. Used to get similar questions a bit, but I haven't seen one in a while ![]()
__________________
(6) |
|
|
|
|
|
|
#7 |
|
unRegistered User
|
Yeah, I got that. thx.
![]() |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|