在 Flash 中使用 XML 附加和定位影片剪辑
我正在尝试构建一个脚本,为 xml 工作表的每个节点附加并定位影片剪辑的实例。但是,我似乎无法让它正确循环。该脚本只是根据 xml 文件中的最后一个节点附加并定位单个影片剪辑。谁能告诉我我做错了什么?!!
这是我的脚本:
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;
}
}
};
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 movieclip 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;
}
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
定位时您没有获得附加的影片剪辑。您的 mc 是在 _root 上生成的,名称为“pin”+ i,因此您需要使用 _root[“pin”+ i] 来获取相关实例。
试试这个:
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 :