开发者

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? 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 开发者_StackOverflowyou can just specify height and width is 100% and then loaded SWF will automatically resize according to stage and Loader's current dimensions?

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. Any comments?


Of cause you don't need to resize automatically, you may set width=100% and 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.

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. If you want it to initialize at 100%, you could do the following inside the loaded 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;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜