Works fantastic. Thanks.
One problem though, in the browser ( IE ) the image shows up small and only resizes when you adjust the browser. Is it possible to have the image in the browser and have the image touching the sides at all times.
Here is a great example site.



----- Original Message ----- From: "Kenneth Kawamoto" <[EMAIL PROTECTED]>
To: "Flash Coders List" <>
Sent: Sunday, February 03, 2008 11:03 PM
Subject: Re: [Flashcoders] Resizing a background image only.And keeping aspectratio.

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

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?



Flashcoders mailing list

Flashcoders mailing list

Reply via email to