0

我已将 AS2 swf 加载到 AS3 swf 中,但 MovieClipLoader 对象的 onLoadInit 函数未执行;这使我的图像没有居中并且没有缩小尺寸(宽度/高度)

如果我直接运行 AS2 swf(图库),它就可以工作。

    listenerObj.onLoadInit = function (target:MovieClip) {
        if (target._height > _root.maxHeight) 
        {
            var ratio = target._height / _root.maxHeight;
            target._height = target._height/ratio;
            target._width = target._width/ratio;
        }
        if (target_mc._width > _root.maxWidth) 
        {
            var ratio = target._width / _root.maxWidth;
            target._height = target._height/ratio;
            target._width = target._width/ratio;
        }
        target._x = ((Stage.width/2)-(target._width/2));
        target._y = ((Stage.height/2)-(target._height/2));
    }
    MCL.addListener(listenerObj);
4

1 回答 1

0

不幸的是,在 AS3 中加载 AS2 电影时,行为和错误存在一些细微差别。我还遇到了您所看到的行为——当影片在 AS3 中加载时,没有任何加载处理程序在侦听器上工作。加载 AVM1 电影时会出现一些奇怪的问题,尤其是在嵌套加载时。

也许您能做的最好的事情是查看 onEnterFrame 以轮询何时加载剪辑。一种方法是观察 _width != 0。这应该在剪辑加载后发生。然后你可以初始化位置:

function onEnterFrame()
{
  if(target._width)
  {
    // your positioning+init code here
    onEnterFrame = null;
  }
}
于 2011-03-28T00:53:34.077 回答