动作脚本(2)问题
|
自从我使用Flash以来已有很长时间了。我要完成的工作是使用变量作为onRollOver事件的触发器。 cname变量返回\“ AUS \”,但是当前不起作用。如果我用
AUS.onRollOver
有用
但是当我使用
cname.onRollOver
它失败。很抱歉n00b问题。
this[cname].onRollOver
也失败了
我的完整代码:
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\");
我完整的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>
没有找到相关结果
已邀请:
1 个回复
车料