Flash XML 数据,单击时显示节点标题
我正在编写一个 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
}
}
}
};
I am working on a Flash AS2 script that adds an instance of a movieclip for each node in an XML file. I have also included titles for each node in the XML file and I would like to display these when a user clicks on one of the individual movieclips. I have played around with clipevents and attachMovie but for the life of me I can't figure out how to approach this problem. Any ideas?
Ok Now with update script - yea!
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
}
}
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
欢迎来到SO。
您可以尝试这样的操作(在创建每个引脚时):(
编辑:将 onRelease 函数更改为使用“this.titleBox”)
详细信息将取决于您希望它的行为方式。
希望这有帮助。
welcome to SO.
You could try something like this (when creating each pin):
(EDIT: changed the onRelease function to use 'this.titleBox')
The details would depend on exactly how you want it to behave.
Hope this helps.