Hello guys,
I am facing problem.
I am loading an external SWF and trying to resize according to the width and height (650 x 500).
I have code for the resize but its clipping from the right and bottom.
Any one?
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var url:URLRequest = new URLRequest("external_swf.swf");
var loader:Loader = new Loader();
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void{
mc.addChild(loader);
mc.x=mc.y=0;
_resize(event.target.width,event.target.height);
}
function _resize(lwidth,lheight):void {
var maxheight = 500;
var maxwidth = 650;
while ((lheight > maxheight) || (lwidth > maxwidth)){
if (lheight-maxheight >= lwidth-maxwidth) {
lwidth = (maxheight / lheight) * lwidth;
lheight = maxheight;
}
else {
lheight = (maxwidth / lwidth) * lheight;
lwidth = maxwidth;
}
}
mc.width = lwidth;
mc.height = lheight;
}
External SWF file fla and swf is attached.
Awaiting your response.
Thanks in advance