It could be cleaner, but here we go:

private function onStageResize(e:Event):void {
  var picRatio:Number = picture_mc.width/picture_mc.height;
  var stageRatio:Number = stage.stageWidth/stage.stageHeight;
  if(picRatio > stageRatio){
     picture_mc.width = stage.stageWidth;
     picture_mc.height = picture_mc.width/picRatio;
  } else {
     picture_mc.height = stage.stageHeight;
     picture_mc.width = picture_mc.height*picRatio;
  }
}

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vlado Krempl wrote:
Hello everyone,


Question: (Using actionscript 3)
How to scale just the background image (photograph) fullscreen in the browser 
but still keep it's aspect ratio.
All the solutions on the internet seem to still be in Actionscript 2.  I'm 
using the code below -
 
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

stage.addEventListener(Event.RESIZE, onStageResize);
function onStageResize(event:Event):void {

picture_mc = ???? }
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I've tried stage.stagewidth and scaleX = stage.width; but they all distort the 
image when resized.

Anyone have a clue?

Thanks.



Vlado

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to