Actionscript (2) 问题
我已经很久没有使用闪光灯了。我想要完成的是使用变量作为 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>
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.
this[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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
this[cname].onRollOver = //一些回调函数
this[cname].onRollOver = //some callback function