Yo.
Working on a simple image fade in, fade out routine here. Standard
setInterval use to run through an array of images. The code works beautifully
until I inserted it into my SWindow class.
Its pretty simple actually. When the media container is created, the first
image is loaded and then setInterval is called to cycle through the
images....pretty standard stuff. But here's where it goes funny. The trace
statements inside nextImage return undefined. They are member functions of the
class so I'd have thought that scope was good but apparently it is not.
I've tried sending setInterval a reference to my SWindow class among other
things. The result is no execution of the nextImage call at all but no errors
are reported. I've provided the code for the three functions in question.
I've tested the code outside of a class....it's from my repository....and I
know it works. I am only having problems after the code is inside a class.
Any help, pointers, or simple slaps in the head for missing something easy are
all appreciated at this point.
Mike
/* ===== load first image - media window only ===== */
private function firstImage( target:MovieClip ):Void {
cur_pos = 0;
trace("Loading first image "+_media[cur_pos]+" into "+target);
mediaLoader.loadClip( _media[cur_pos], target );
picture_num();
trace("firstImage this = "+this); // Returns [object Object] as it should
- scope does belong to my class
intervalID = setInterval( nextImage, 5000 );
}
/* ===== load next image - media window only ===== */
private function nextImage():Void {
trace(this); // traces out undefined
trace("Loading: "+_media[cur_pos]); // traces out undefined
mediaLoader.loadClip( _media[cur_pos], h_mc );
picture_num();
}
/* ===== increment image number - media window only ===== */
private function picture_num():Void {
if(cur_pos > _media.length - 1) {
cur_pos = 0;
} else {
cur_pos += 1;
}
trace("Current: "+cur_pos);
}