Flash AS3 LoaderMax Resizing Issue - How to keep the same scale mode on stage resize
I'm using the loadermax class from greensock in order to load an image which matches the screen's width and height, using a scaleMode 开发者_StackOverflow社区of proportionalOutside. The problem is, if I resize the stage, the image does not scale with it. Is there a way to resize the image while maintaining loaderMax's scaleMode?
You may have to do the calculations yourself. If your matching the stage size it should be pretty simple:
var loader:Loader = new Loader();
function stageResizeHandler(event:Event):void {
loader.width = stage.stageWidth;
loader.height = stage.stageHeight;
}
function loaderCompleteHandler(event:Event):void {
stage.addEventListener(Event.RESIZE, stageResizeHandler);
}
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
this.addChild(loader);
You'll likely have to finagle that code a little depending on your setup, but I (or someone on sof) can help you through it if you get stuck.
Here's the code I used to scale this proportionally:
var contentWidth = stage.stageWidth / stage.stageHeight; //used for tracking aspect ratio on fs media
var contentHeight = stage.stageHeight / stage.stageWidth; //used for tracking aspect ratio on fs media
if ((stage.stageHeight / stage.stageWidth) < contentHeight) {
fsMedia.fsContainer.width = stage.stageWidth;
fsMedia.fsContainer.height = contentHeight * fsMedia.width;
} else {
fsMedia.fsContainer.height = stage.stageHeight;
fsMedia.fsContainer.width = contentWidth * fsMedia.height;
}
精彩评论