[résolut]erreur avec array et push
C'est bon, j'ai trouvé.
Bonjour,
Avec la classe suivante les actions trace me réponde que les membres de mon objet sont undefined, malgrés qu'ils soient définis en début de classe (les deux array) :
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 47 48
|
import starContainer;
import constellation;
class planetarium extends Object{
private var lstEtoiles = new Array;
private var lstConst = new Array;
private var ciel:XMLNode;
public function planetarium( xmlFile:String ){
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(success){
if(success){
// fill sky with all stars -- starContainer
trace("lstEtoiles length : " + lstEtoiles.length);
trace("lstConst length : " + lstConst.length);
ciel = xml.firstChild;
var childs = ciel.childNodes;
var node:XMLNode = childs[0].firstChild;
while(node){
var etoile = _root.attachMovie("starContainer", node.attributes.nom, _root.getNextHighestDepth());
etoile.initialize(node);
lstEtoiles.push(etoile);
trace("lstEtoiles length : " + lstEtoiles.length);
node = node.nextSibling;
}
// fill sky with constellations
node = childs[1].firstChild;
while(node){
var const = _root.attachMovie("cstl", node.attributes.nom, _root.getNextHighestDepth());
const.initialize(node);
lstConst.push(const);
trace("lstConst length : " + lstConst.length);
node = node.nextSibling;
}
}
}
xml.load(xmlFile);
var a = 1;
}
public function showLinks(){
for(var i = 0; i< lstConst.length; i++){
lstConst[i].drawLinks();
}
}
} |
EDIT :
j'ai essayé avec lstEtoiles:Array et lstEtoiles = new Array(); mais rien ne marche.
EDIT :
Bon, je viens de trouver.
Le this dans la fonctin xml.OnLoad n'est pas ma classe mais le xml.
Mais du coup comment envoyer la récupératin des données à l'objet appellant ?