解决FLASH导航条AS代码的错误:实例名不能为纯数字,链接未定义。

作者:我就是个世界 发表于:2011-01-13
在修改一个FLASH导航条的时候,出现了AS代码的错误:实例名不能为纯数字,链接未定义。

[b]原因:[/b]FLASH高版本中实例名不可以为纯数字,必须是字母开头,而原先的FLASH是低版本的FLASH做的,实例名为纯数字,在添加新的按钮后,AS代码不能用了,需要修改:
  修改重定义所有按钮实例名为a1、a2、a3... 这样的格式;
  修改所有的 this[i] 为 this["a" + i];
  修改链接link数组代码link[] 为 link["a" + 1]
[b]以下是完整as代码:[/b][separator]
[code]
link = new Array();
link["a" +1] = "/";
link["a" +2] = "/index.php?c=msg&ts=aboutus";
link["a" +3] = "/index.php?c=list&cs=news";
link["a" +4] = "/index.php?c=list&cs=daily";
link["a" +5] = "/index.php?c=list&cs=pics";
link["a" +6] = "/index.php?c=list&cs=pros";
link["a" +7] = "/index.php?c=list&ms=jobs";
link["a" +8] = "/index.php?c=list&ms=contactus";
link["a" +9] = "/index.php?c=list&ms=book";
numOfMenu = 9;
_global.active = m;
_global.subActive = s;
_global.over = active;
for (i = 1; i <= numOfMenu; i++)
{
    this["a"+i].bg.onRollOver = function ()
    {
        _global.over = this._parent._name;
    };
    this["a"+i].bg.onRollOut = this["a"+i].bg.onDragOut = function ()
    {
        _global.over = active;
    };
    this["a"+i].bg.onRelease = function ()
    {
        getURL(link[this._parent._name], "_self");
    };
    this["a"+i].onEnterFrame = function ()
    {
        var _loc2 = this;
        if (over == _loc2._name)
        {
            _loc2.direction = "next";
            _loc2.nextFrame();
            return;
        } // end if
        _loc2.direction = "prev";
        _loc2.prevFrame();
    };
} // end of for
if (over)
    {
  point._x = point._x + (this[over]._x - point._x) * 3.000000E-001;
}
    else
    {
  point._x = point._x + (-100 - point._x) * 3.000000E-001;
} this.onEnterFrame = function() {
// end else if
};
[/code]

分享:

扫一扫在手机阅读、分享本文

请发表您的评论