AS2 Gallery swf 加载到主 Web AS3 swf
我已将 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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,在 AS3 中加载 AS2 影片时,行为和错误存在一些细微的差异。我也经历过您所看到的行为——当电影在 AS3 中加载时,没有任何加载处理程序在侦听器上工作。加载 AVM1 影片时,特别是嵌套加载时,会出现一些奇怪的问题。
也许您能做的最好的事情就是查看 onEnterFrame 来轮询剪辑何时加载。一种方法是观察 _width != 0。这应该在剪辑加载后发生。然后你可以初始化位置:
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: