开发者

Flash XML Data, Display Node Title on Click

开发者 https://www.devze.com 2022-12-21 01:23 出处:网络
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

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.getNextHig开发者_如何转开发hestDepth());
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
}

}
}
};


welcome to SO.

You could try something like this (when creating each pin):

_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
}

(EDIT: changed the onRelease function to use 'this.titleBox')

The details would depend on exactly how you want it to behave.

Hope this helps.

0

精彩评论

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

关注公众号