简体   繁体   English

AS2图库SWF已加载到主网站AS3 SWF

[英]AS2 Gallery swf loaded into Main web AS3 swf

I've loaded a AS2 swf into a AS3 swf but the onLoadInit function for a MovieClipLoader object isn't executing; 我已将AS2 SWF加载到AS3 SWF中,但是MovieClipLoader对象的onLoadInit函数未执行; which leaves my images not centered and not reduced in dimensions (width/height) 这使我的图像没有居中并且尺寸(宽度/高度)没有减小

It works if i run the AS2 swf (gallery) directly. 如果我直接运行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);

There are unfortunately some subtle differences in behavior and bugs when loading an AS2 movie in AS3. 不幸的是,在AS3中加载AS2电影时,行为和错误之间存在细微的差别。 I also experience the behavior you're seeing--none of the load handlers work on the listener when the movie is loaded in AS3. 我还遇到了您所看到的行为-将影片加载到AS3中时,没有任何加载处理程序在侦听器上起作用。 There are some strange issues when loading AVM1 movies, particularly when nesting loads. 加载AVM1电影时有一些奇怪的问题,尤其是在嵌套加载时。

Perhaps the best you can do is to look onEnterFrame to poll for when the clips are loaded. 也许您能做的最好的就是查看onEnterFrame以便在加载剪辑时进行轮询。 One way is to watch for _width != 0. This should happen once the clip has loaded. 一种方法是监视_width!=0。一旦剪辑被加载,就应该发生这种情况。 Then you can initialize the position: 然后可以初始化位置:

function onEnterFrame()
{
  if(target._width)
  {
    // your positioning+init code here
    onEnterFrame = null;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM