简体   繁体   English

加载器和加载的 SWF 的自动调整大小

[英]auto resize of Loader and loaded SWF

is there a way to set the loaded SWF's height and width to always use 100% of the Loader's height and width?有没有办法将加载的 SWF 的高度和宽度设置为始终使用 Loader 的高度和宽度的 100%? pretty much like when you're embedding a swf to an HTML page... I know that you can do this by setting the width and height of the Loader on every stage resize, but is there another way wherein you can just specify height and width is 100% and then loaded SWF will automatically resize according to stage and Loader's current dimensions?就像您将 swf 嵌入到 HTML 页面时一样...我知道您可以通过在每个阶段调整大小时设置加载器的宽度和高度来做到这一点,但是还有另一种方法可以让您指定高度和宽度为 100%,然后加载的 SWF 会根据舞台和加载器的当前尺寸自动调整大小?

try loaded a SWF file which has coordinates based listeners and it seems that the loaded SWF doesn't reposition its listeners correctly even if the stage is already resized... take this swf for example http://www.mofunzone.com/online_games/the_simple_game.shtml , i tried using an SWFLoader in flex which scales the content and also a normal AS3 flash.display.Loader and it seems that both fails to reposition the listeners correctly.尝试加载具有基于坐标的侦听器的 SWF 文件,即使舞台已经调整大小,加载的 SWF 似乎也无法正确重新定位其侦听器......以这个 swf 为例http://www.mofunzone.com/online_games /the_simple_game.shtml ,我尝试在 flex 中使用 SWFLoader 来缩放内容以及普通的 AS3 flash.display.Loader ,似乎两者都无法正确重新定位听众。 Any comments?任何意见?

Of cause you don't need to resize automatically, you may set width=100% and height=100% .当然,您不需要自动调整大小,您可以设置width=100%height=100% Look here for example.例如看这里

There isn't a way to specifically set the Loader to size your loaded swf upon completion of a load.没有办法专门设置加载程序以在加载完成后调整加载的 swf 大小。

If you always want your loaded swf to be 100% of the stage's width and height, you WOULD need to do a stage resize listener and resize it inside the event handler.如果你总是希望你加载的 swf 是舞台宽度和高度的 100%,你需要做一个舞台调整大小监听器并在事件处理程序中调整它的大小。 If you want it to initialize at 100%, you could do the following inside the loaded swf :如果您希望它以 100% 初始化,您可以在加载的 swf中执行以下操作:

import flash.events.Event

addEventListener (Event.ADDED_TO_STAGE, onAddedToStage);

function onAddedToStage (e:Event):void{
    removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage)
    this.width = stage.stageWidth;
    this.height = stage.stageHeight;
}

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

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