, Jr. Member
You have to keep the aspect ratio to solve the problem.
Here is my resize function for example. You can change and use it for your needs.
private function SetSize(width:Number, height:Number, pos:Point, keepAspectRato:Boolean = true, fixedWidth:Number = 1280):void
{
var aspectRatio:Number;
var starlingHeight:Number;
var starlingWidth:Number;
var containerHeight:Number;
var containerWidth:Number;
var delta:Number;
aspectRatio = 9.0/16.0;
if (keepAspectRato)
{
starlingWidth = fixedWidth;
starlingHeight = starlingWidth*aspectRatio;
containerWidth = width;
containerHeight = containerWidth*aspectRatio;
if (containerHeight > height)
{
delta = height/containerHeight;
starlingHeight *= delta;
starlingWidth *= delta;
containerHeight *= delta;
containerWidth *= delta;
}
starlingHeight = Math.round(starlingHeight);
starlingWidth = Math.round(starlingWidth);
containerHeight = Math.round(containerHeight);
containerWidth = Math.round(containerWidth);
}
else
{
starlingWidth = Math.round(fixedWidth);
starlingHeight = Math.round(starlingWidth*aspectRatio);
containerWidth = Math.round(width);
containerHeight = Math.round(height);
}
starlingBackLayers.Resize(starlingWidth, starlingHeight);
starlingFrontLayers.Resize(starlingWidth, starlingHeight);
view.x = Math.round((width-containerWidth)/2);
view.y = Math.round((height-containerHeight)/2);
view.height = containerHeight;
view.width = containerWidth;
stage3DProxy.x = Math.round(pos.x+(width-containerWidth)/2);
stage3DProxy.y = Math.round(pos.y+(height-containerHeight)/2);
stage3DProxy.height = containerHeight;
stage3DProxy.width = containerWidth;
}