Actionscript (2) 问题

发布于 2024-11-14 22:27:23 字数 2025 浏览 1 评论 0原文

我已经很久没有使用闪光灯了。我想要完成的是使用变量作为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆萌少年 2024-11-21 22:27:23

this[cname].onRollOver = //一些回调函数

this[cname].onRollOver = //some callback function

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文