All pastes #356871 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-15 09:47 UTC
rendered paste body
var listenerStageResize:Object = new Object();
listenerStageResize.onResize = function()
{
   if    (Stage.width < Stage.height || objectBackground._width < objectBackground._height)
   {
       objectBackground._height = Stage.width / (objectBackground._width / objectBackground._height);
       objectBackground._width = Stage.width;
   }
   
   else if    (Stage.width > Stage.height || objectBackground._width > objectBackground._height)
   {
       objectBackground._width = Stage.height / (objectBackground._height / objectBackground._width);
       objectBackground._height = Stage.height;
   }
   
   objectBackground._x = (Stage.width / 2) - (objectBackground._width / 2);
   objectBackground._y = (Stage.height / 2) - (objectBackground._height / 2);
};

Stage.addListener(listenerStageResize);

// Call the function at the start to ensure the first frame is rendered correctly as well.
listenerStageResize.onResize();