Actionscript (2) Question
its been ages since i've used flash. What i'm trying to accomplish is use a variable as a trigger for the onRollOver event. The cname variable returns "AUS" however its currently not working. If i use
AUS.onRollOver
it works
but when i use
cname.onRollOver
it fails. Sorry for n00b question.
thi开发者_开发技巧s[cname].onRollOver
also fails
My Complete Code:
function loadXML(loaded) {
if (loaded) {
_root.country = this.firstChild.childNodes;
var cname = country[0].childNodes[0].firstChild.nodeValue;
var clink = country[0].childNodes[1].firstChild.nodeValue;
var cregion = country[0].childNodes[2].firstChild.nodeValue;
var ctext = country[0].childNodes[3].firstChild.nodeValue;
trace(cname);
trace(clink);
trace(cregion);
trace(ctext);
this[cname].onRollOver = function() {
var colorful = new Color(this);
colorful.setRGB(0x0099d9);
subline.text = ctext;
};
this[cname].onRollOut = function() {
var colorful = new Color(this);
colorful.setRGB(0x939598);
subline.text = "";
};
this[cname].onRelease = function(){
getURL(clink, _self);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("countries.xml");
my complete xml (countries.xml):
<?xml version="1.0"?>
<countries>
<country>
<name>AUS</name>
<hyperlink>http://www.google.com.au/</hyperlink>
<region>australasia</region>
<infotext>Welcome to Australia</infotext>
</country>
<country>
<name>USA</name>
<hyperlink>http://www.google.com/</hyperlink>
<region>australasia</region>
<infotext>Welcome to America</infotext>
</country>
</countries>
this[cname].onRollOver = //some callback function
精彩评论