Fonction récursive dans une classe
Bonjour, voilà mon soucis, j'ai décidé de passer mes script Js en orienté objet pour faciliter la maintenance, mais j'ai certaines difficultés avec une classe :
La classe en question :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| function CFadingMenu()
{
//Initialisation des propriétés d'instance
this.isOver = false;
this.transparence = 0;
};
//Définition des méthodes de l'objet
CFadingMenu.prototype.downOpacity = function()
{
if (this.isOver == false)
{
document.getElementById("menugris").style.filter = "alpha(opacity="+this.transparence+")";
document.getElementById("menugris").style.opacity = this.transparence / 100;
if (this.transparence <= 100)
{
this.transparence += 10;
setTimeout("this.downOpacity();",50);
}
}
};
CFadingMenu.prototype.upOpacity = function()
{
if (this.isOver == true)
{
document.getElementById("menugris").style.filter = "alpha(opacity="+this.transparence+")";
document.getElementById("menugris").style.opacity = this.transparence / 100;
if (this.transparence >= 0)
{
this.transparence = this.transparence - 10;
setTimeout("this.upOpacity();",50);
}
}
};
CFadingMenu.prototype.mouseOver = function()
{
this.isOver = true;
this.upOpacity();
};
CFadingMenu.prototype.mouseOut = function()
{
this.isOver = false;
this.downOpacity();
}; |
Me sort un message d'erreur du genre
Code:
1 2
| this.downOpacity is not a function
[Break on this error] setTimeout("this.downOpacity();",50); |
Alors je ne comprend pas où se trouve l'erreur, j'ai bien essayé de passer l'objet en paramètre mais ça n'a pas arrangé les choses :S
Merci !