2010-02-22 8 views
0

En essayant de construire un script qui attache et positionne une instance d'un MovieClip pour chaque nœud d'une feuille xml. Cependant, je n'arrive pas à le faire tourner correctement. Le script consiste simplement à attacher et à positionner un seul MovieClip en fonction du dernier nœud du fichier XML. Quelqu'un peut-il me dire ce que je fais mal? !!Joindre et positionner Movieclips avec XML dans Flash

Voici mon script:

var myXML:XML = new XML(); 
myXML.ignoreWhite=true; 
myXML.load("map.xml"); 
myXML.onLoad = function(success) { 
if (success) { 
var myPin = myXML.firstChild.childNodes; 
for (i=0; i<myPin.length; i++) { 

var imageNumber = i+1; 

_root.attachMovie("box", "pin"+i, _root.getNextHighestDepth()); 
var xpos = myPin[i].attributes.xpos; 
var ypos = myPin[i].attributes.ypos; 
_x = xpos; 
_y = ypos; 

} 
} 
}; 

Répondre

0

Vous ne recevez pas le MovieClip attaché quand positionnant. Vos mc sont générés sur _root avec le nom "pin" + i, vous devez donc utiliser _root ["pin" + i] pour obtenir l'instance correspondante.

Essayez ceci:

_root.attachMovie("box", "pin"+i, _root.getNextHighestDepth()); 
var xpos = Number(myPin[i].attributes["xpos"]); 
var ypos = Number(myPin[i].attributes["ypos"]); 
_root["pin" + i]._x = xpos; 
_root["pin" + i]._y = ypos; 
+0

Eh oui Ce it- fait Merci! – Thomas