我正在编写一个 Flash AS2 脚本,该脚本为 XML 文件中的每个节点添加一个影片剪辑的实例。我还在 XML 文件中包含每个节点的标题,我希望在用户单击其中一个单独的影片剪辑时显示这些标题。我玩过clipevents 和attachMovie,但对于我的生活,我无法弄清楚如何解决这个问题。有任何想法吗?
好的,现在使用更新脚本 - 是的!
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 pinNumber = i+1;
_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;
_root["pin" + i].popup.titleBox.text = myPin[i].firstChild.nodeValue;
_root["pin" + i].popup._visible = false;// hide the title to begin with
_root["pin" + i].onRelease = function () { //when the pin is clicked...
_root["pin" + i].popup._visible=!_root["pin" + i].popup._visible; //toggle the titleBox's visibility
}
}
}
};