0

我正在编写一个 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
}

}
}
};
4

1 回答 1

0

欢迎来到SO。

您可以尝试这样的事情(创建每个引脚时):

_root["pin" + i].titleBox._visible = false;// hide the title to begin with

_root["pin" + i].onRelease = function () { //when the pin is clicked...
this.titleBox._visible=!this.titleBox._visible; //toggle the titleBox's visibility
}

(编辑:将 onRelease 函数更改为使用 'this.titleBox')

细节将取决于您希望它的行为方式。

希望这可以帮助。

于 2010-02-22T11:55:38.233 回答