如何解决动作脚本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>
解决方法
this [cname] .onRollOver = //一些回调函数
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。