我在 ActionScript 2.0 中遇到了一些奇怪的行为。我正在尝试向舞台添加一定数量的页面(MovieClips),同时将引用存储在一个方便的数组中以供以后访问。这是我的代码(假设所有变量都已正确声明):
_adPages = new Array();
_adPages[0] = adPageTrack.attachMovie("adPage", "adpage0" + 0, getNextHighestDepth());
_adPages[0].init( _adItems[0] );
_adPages[0]._x = 0 * 10;
_adPages[1] = adPageTrack.attachMovie("adPage", "adpage0" + 1, getNextHighestDepth());
_adPages[1].init( _adItems[1] );
_adPages[1]._x = 1 * 10;
_adPages[2] = adPageTrack.attachMovie("adPage", "adpage0" + 2, getNextHighestDepth());
_adPages[2].init( _adItems[2] );
_adPages[2]._x = 2 * 10;
_adPages[3] = adPageTrack.attachMovie("adPage", "adpage0" + 3, getNextHighestDepth());
_adPages[3].init( _adItems[3] );
_adPages[3]._x = 3 * 10;
trace(_adPages);
for (var i:Number = 0; i < 4; i++) {
trace("Ad page x coordinate: " + _adPages[i]._x);
trace("Ad page y coordinate: " + _adPages[i]._y);
}
这最初是一个循环,它已被分解,因此我可以更仔细地检查它。注意跟踪语句。它们应该输出一组 MovieClip 句柄,后跟一个 x 和 y 坐标列表。相反,他们输出这个:
,,,_level0.main.adPageTrack.adpage03
Ad page x coordinate: undefined
Ad page y coordinate: undefined
Ad page x coordinate: undefined
Ad page y coordinate: undefined
Ad page x coordinate: undefined
Ad page y coordinate: undefined
Ad page x coordinate: 30
Ad page y coordinate: 0
除了最后一个要设置的项目外,所有项目都已被删除。如果我删除第四个项目,那么第三个项目现在完好无损,而其他所有项目都消失了。
有谁知道这里发生了什么?这是一个错误还是我只是错过了一些关于语言的东西?