开发者

Attaching and Positioning Movieclips with XML in Flash

Im trying to build a script that attaches and positions an instance of a movieclip for each node of an xml sheet. However, I can't seem to get it to loop properly. The script is simply attaching and positioning a single moviecli开发者_StackOverflowp according to the last node in the xml file. Can anyone tell me what I am doing wrong?!!

Here is my 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;

}
}
};


You are not getting the attached movieclip when positionning. Your mc are generated on _root with the name "pin" + i, so you need to use _root["pin" + i] to get the related instance.

Try this :

_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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜