bboese
07-31-2005, 02:29 AM
I'm trying to create a class for use in an image gallery. This class would be used in a thumbnail image to control the fadein/out of the displayed image. Inside my thumbnail I create a new instance of the "fader" class and call the fade function. The clip that is referenced then fades out. See the code below.
Once the alpha of the clip hits zero then it tries to clear fadeInterval, and this is where the problem is showing up. The function fadeOut keeps executing infinitely even after the clearInterval call is made. I watched the fadeInterval variable using trace and noticed that it always seems to be undefined when referenced inside the fadeOut function. I assume I'm missing something with the inheritance, but can't seem to figure out why I can't clear the Interval. Any help on this would be greatly appreciated.
In the root Movie
fader = function() {}
fader.prototype.fadeInterval;
fader.prototype.delay = 10;
fader.prototype.clip;
fader.prototype.fadeOut = function (clip)
{
if(clip._alpha > 0) {
clip._alpha -=5;
}
if(clip._alpha <= 0) {
clearInterval(this.fadeInterval);
}
}
fader.prototype.fade = function ()
{
this.fadeInterval = setInterval(this.fadeOut, this.delay, this.clip);
}
In the thumbnail
on (release) {
myfade = new _root.fader;
myfade.clip=_root.test1;
myfade.fade();
}
Once the alpha of the clip hits zero then it tries to clear fadeInterval, and this is where the problem is showing up. The function fadeOut keeps executing infinitely even after the clearInterval call is made. I watched the fadeInterval variable using trace and noticed that it always seems to be undefined when referenced inside the fadeOut function. I assume I'm missing something with the inheritance, but can't seem to figure out why I can't clear the Interval. Any help on this would be greatly appreciated.
In the root Movie
fader = function() {}
fader.prototype.fadeInterval;
fader.prototype.delay = 10;
fader.prototype.clip;
fader.prototype.fadeOut = function (clip)
{
if(clip._alpha > 0) {
clip._alpha -=5;
}
if(clip._alpha <= 0) {
clearInterval(this.fadeInterval);
}
}
fader.prototype.fade = function ()
{
this.fadeInterval = setInterval(this.fadeOut, this.delay, this.clip);
}
In the thumbnail
on (release) {
myfade = new _root.fader;
myfade.clip=_root.test1;
myfade.fade();
}