Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

ciblage de mon prototype

1 réponse
Avatar
nolive
Bonjour ,

Pouvez vous me dire pourquoi dans l'exemple ci dessous je n'arrive pas à
lancer ma fonction createGalerie ?

qu'est ce qui cloche dans cette partie de code ???
//Quand la liste est chargée
imglist.onLoad = function(success)
{

this._parent.createGalerie(imglist);
trace("success");
};

merci pour votre aide

nolive





code complet
Code:

//-----------------------------------------// création de la classe
//--------------------------------------------------------------------------------------------------------
Magalerie = function ()
{
}

// création de la chaine d'héritage
//--------------------------------------------------------------------------------------------------------
Magalerie.prototype= new MovieClip();

//--------------------------------------------------------------------------------------------------------
// attachement du clip à la classe
Object.registerClass("Magalerie",Magalerie);

Magalerie.prototype.onLoad = function ()
{
this.Create_XML();
}

//Récupération XML
Magalerie.prototype.Create_XML = function ()
{
var imglist = new XML();
//On ignore les blancs dans le xml
imglist.ignoreWhite = true;
trace(this._name);
//On charge
imglist.load("http://127.0.0.1/galerie_nolive/sample/getImgList.php");
//imglist.load("php/getImgList.php");

//Quand la liste est chargée
imglist.onLoad = function(success)
{
this._parent.createGalerie(imglist);
trace("success");
};
}

//Création de la galerie
Magalerie.prototype.createGalerie = function (imglist)
{
trace("coucou");
//liste des images
var noeuds = imglist.firstChild.childNodes;
trace(imglist);
//On parcours la liste
for (var i = 0; i<noeuds.length; i++)
{
//nom de l'image
var nom = noeuds[i].attributes.name;
//On crée un clip vide et le positionne
var img = this.createEmptyMovieClip("img"+i, i);
img._x = (i%5)*110+10;
img._y = Math.floor(i/5)*110+10;
// trace("img._x : "+img._x);
// trace("img._y : "+img._y);
// trace("---------------");
//On charge la miniature
var view = img.createEmptyMovieClip("view", 0);
view.loadMovie("mini/"+nom);
//On enregistre les infos
img.nom = "images/"+nom;
img.width = noeuds[i].attributes.width;
img.height = noeuds[i].attributes.height;
//On affiche l'image dans un popup lors du clic
img.onRelease = function()
{
this._parent.popup(this.nom, this.width, this.height);
};
}
}
//Lance une popup
Magalerie.prototype.popup = function (url, width, height)
{
var lalargeur = Math.min(Number(width)+20,
System.capabilities.screenResolutionX);
var lahauteur = Math.min(Number(height)+20,
System.capabilities.screenResolutionY);
var t = (System.capabilities.screenResolutionY-lahauteur)/2;
var l = (System.capabilities.screenResolutionX-lalargeur)/2;
var propriete =
"width="+lalargeur+",height="+lahauteur+",top="+t+",left="+l;
if (lalargeur == System.capabilities.screenResolutionX || lahauteur
== System.capabilities.screenResolutionY)
{
propriete += ",scrollbars=1";
}
getURL("javascript:void(window.open('"+url+"','image"+width+"','"+propriete+"'));");
}


begin 666 icon_cry.gif
M1TE&.#EA#P`/`,00`/_J`$5%10```/_.`/_)`/Z=`/^T`/_^D__]$_______
MQ___Z__E``",V(&[UEY>7@``````````````````````````````````````
M`````````````````````````"'_"TY%5%-#05!%,BXP`P$````A^00%'@`0
M`"P`````#P`/```%7" DBD%9CBA4+LIQ#"<:L @"W$,1C$$KW$!!;J<Z_(!!
MF$IA0R()NL#!)C@"J@""H71P.K6EIO<&#@S&-P9T9[Y5WUFE:C!X(!F/(8].
MZ/?U,@$&@P91*3PF1",A`"'Y! 44`! `+ 0`!0`'``<```41("1 Y$B>9-*<
M38*^,&R>0@@`(?D$!0H`$ `L! `(``<``0``!09@XD"DDX0`(?D$!0H`$ `L
M! `'``<``P``!0H@((Y DHRFB28A`"'Y! 4*`! `+ 0`" `'``,```4+( !
MI$B>9()"20@`(?D$!0H`$ `L! `'``<`! ``!0U@T@!DDY!HJ@)"VP(A`"'Y
M! 4*`! `+ 0`" `'``$```4&8.) I).$`"'Y! 4*`! `+ 0`!P`'``,```4*
M("".0)*,IHDF(0`A^00%"@`0`"P$``4`!P`&```%#R $0.1(GF@*F"*+)FD2
#`@`[
`
end

1 réponse

Avatar
\(-: tatactic :-\)
STP ATTENTION AUX USAGES [FLAMX] DANS LE SUJET

sinon:
this._parent???
dans ta fonction onLoad tu es dans une instance d'un objet XML à qui tu peux
passer une ref

Magalerie = function () {
};
Magalerie.prototype.Create_XML = function(xmlPath) {
var imglist = new XML();
imglist.targ = this;
imglist.ignoreWhite = true;
imglist.load(xmlPath);
imglist.onLoad = function(succes) {
if (succes) {
this.targ.createGalerie(this);
} else {
trace("error loading XML");
}
};
};
Magalerie.prototype.createGalerie = function(list) {
trace("pictures to load in "+this.id+": ");
for (var i = 0; i<list.childNodes[0].childNodes.length; i++) {
trace("loading code for :
"+list.childNodes[0].childNodes[i].attributes.id);
}
};
gal = new Magalerie();
gal.id = "gal1";
gal.Create_XML("gal.xml");


/*
gal.xml <galery>
<image id="img_1.jpg"/>
<image id="img_2.jpg"/>
<image id="img_3.jpg"/>
<image id="img_4.jpg"/>
<image id="img_5.jpg"/>
<image id="img_6.jpg"/>
</galery>
*/


"nolive" a écrit dans le message de news:
clj0ck$p2s$
Bonjour ,

Pouvez vous me dire pourquoi dans l'exemple ci dessous je n'arrive pas à
lancer ma fonction createGalerie ?

qu'est ce qui cloche dans cette partie de code ???
//Quand la liste est chargée
imglist.onLoad = function(success)
{

this._parent.createGalerie(imglist);
trace("success");
};

merci pour votre aide

nolive





code complet
Code:

//-----------------------------------------// création de la classe

//--------------------------------------------------------------------------------------------------------
Magalerie = function ()
{
}

// création de la chaine d'héritage

//--------------------------------------------------------------------------------------------------------
Magalerie.prototype= new MovieClip();


//--------------------------------------------------------------------------------------------------------
// attachement du clip à la classe
Object.registerClass("Magalerie",Magalerie);

Magalerie.prototype.onLoad = function ()
{
this.Create_XML();
}

//Récupération XML
Magalerie.prototype.Create_XML = function ()
{
var imglist = new XML();
//On ignore les blancs dans le xml
imglist.ignoreWhite = true;
trace(this._name);
//On charge

imglist.load("http://127.0.0.1/galerie_nolive/sample/getImgList.php");
//imglist.load("php/getImgList.php");

//Quand la liste est chargée
imglist.onLoad = function(success)
{
this._parent.createGalerie(imglist);
trace("success");
};
}

//Création de la galerie
Magalerie.prototype.createGalerie = function (imglist)
{
trace("coucou");
//liste des images
var noeuds = imglist.firstChild.childNodes;
trace(imglist);
//On parcours la liste
for (var i = 0; i<noeuds.length; i++)
{
//nom de l'image
var nom = noeuds[i].attributes.name;
//On crée un clip vide et le positionne
var img = this.createEmptyMovieClip("img"+i, i);
img._x = (i%5)*110+10;
img._y = Math.floor(i/5)*110+10;
// trace("img._x : "+img._x);
// trace("img._y : "+img._y);
// trace("---------------");
//On charge la miniature
var view = img.createEmptyMovieClip("view", 0);
view.loadMovie("mini/"+nom);
//On enregistre les infos
img.nom = "images/"+nom;
img.width = noeuds[i].attributes.width;
img.height = noeuds[i].attributes.height;
//On affiche l'image dans un popup lors du clic
img.onRelease = function()
{
this._parent.popup(this.nom, this.width, this.height);
};
}
}
//Lance une popup
Magalerie.prototype.popup = function (url, width, height)
{
var lalargeur = Math.min(Number(width)+20,
System.capabilities.screenResolutionX);
var lahauteur = Math.min(Number(height)+20,
System.capabilities.screenResolutionY);
var t = (System.capabilities.screenResolutionY-lahauteur)/2;
var l = (System.capabilities.screenResolutionX-lalargeur)/2;
var propriete =
"width="+lalargeur+",height="+lahauteur+",top="+t+",left="+l;
if (lalargeur == System.capabilities.screenResolutionX ||
lahauteur == System.capabilities.screenResolutionY)
{
propriete += ",scrollbars=1";
}

getURL("javascript:void(window.open('"+url+"','image"+width+"','"+propriete+"'));");
}