Programmation orientée objet slideshow
cs_jerame
Messages postés
33
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
28 novembre 2005
-
27 nov. 2005 à 21:17
cs_jerame
Messages postés
33
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
28 novembre 2005
-
28 nov. 2005 à 20:04
Bonsoir à tous,
Voilà, jai récupéré un script qui fonctionne bien, et je voulais le factoriser pour en faire une class,
voici le code :
<tt>
/*
* Affiche les images du tableau de photos toutes les intervalTemps
*/
function Diapo(tabPthoto,intervalTemps)
{
this.howMany = tabPthoto.length;
this.intervalTemps = 1000*intervalTemps;
this.PicCurrentNum = 0;
this.PicCurrent = new Image();
this.PicCurrent.src = tabPthoto[this.PicCurrentNum];
}
/* les methodes */
function slideshow()
{
this.PicCurrentNum++;
if (this.PicCurrentNum == this.howMany)
{
this.PicCurrentNum=0;
}
this.PicCurrent.src = this.tabPthoto[this.PicCurrentNum];
document.getElementById("ChangingPix").src = this.PicCurrent.src;
}
Diapo.prototype.slideshow=slideshow;
function startPix()
{
setInterval("this.slideshow()", this.intervalTemps);
}
Diapo.prototype.startPix=startPix;
</tt>
Malheureusement, il ne fonctionne pas, les attributs (propriétés) dans
le constructeurs ne sont pas répércuté à lappel des méthodes, jai
donc lerreur suivante : this.PicCurrent.src has no propertie, et quand
je fais un alert (this.PicCurrentNum) dans la méthode slideShow, la
variable nest pas définie.
Pouvez vous me dire pourquoi et comment je peux remedier à ca merci