开发者

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; which leaves my images not centered and not reduced in dimensions (width/height)

It works if i run the AS2 swf (gallery) directly.

    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. I also experience the behavior you're seeing--none of the load handlers work on the listener when the movie is loaded in AS3. There are some strange issues when loading AVM1 movies, particularly when nesting loads.

Perhaps the best you can do is to look onEnterFrame to poll for when the clips are loaded. One way is to watch for _width != 0. This should happen once the clip has loaded. Then you can initialize the position:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜