Skip to main content
Inspiring
February 3, 2014
Answered

AIR Android fullscreen masked background -- plz help

  • February 3, 2014
  • 1 reply
  • 705 views

Hi,

I got the follow basic code making my backgound reszie to the stage dimentions:

public function main()      {

     stage.scaleMode = StageScaleMode.NO_SCALE;

     stage.align = StageAlign.TOP_LEFT;

     sw = stage.stageWidth

     sh = stage.stageHeight

     setPosition();

     stage.addEventListener(Event.RESIZE, resizeLayout);

}

private function setPosition():void     {

     bg.width = stage.stageWidth;

     bg.height = stage.stageHeight;

     bg.x = 0

     bg.y = 0

}

private function resizeLayout(e:Event):void     {

     setPosition();

}

The problem is if the bg movieclip is a has a mask inside of it, the dimentions are not of the masked area but of the total size.

Any ideas how i can get around that will be appriciated.

Thx Pavel

This topic has been closed for replies.
Correct answer moccamaximum

the factor you have to multiply the dimensions your bg with depends on the stage/mask ratio.

the formula is basically this:

(x*bg.width/bg.width) = stage.width/mask.width;

you need x therefore:

x= stage.width/mask.width;

that changes your function to:

private function setPosition():void     {
     bg.scaleX = stage.width/bg.mask.width;
     bg.scaleY= stage.height/bg.mask.height;
     bg.x = 0
     bg.y = 0

// the regristtration point of your mask should be aligned with the regirstrationpoint of your bg otherwise you have to calculate relative nullpoint

1 reply

moccamaximumCorrect answer
Inspiring
February 3, 2014

the factor you have to multiply the dimensions your bg with depends on the stage/mask ratio.

the formula is basically this:

(x*bg.width/bg.width) = stage.width/mask.width;

you need x therefore:

x= stage.width/mask.width;

that changes your function to:

private function setPosition():void     {
     bg.scaleX = stage.width/bg.mask.width;
     bg.scaleY= stage.height/bg.mask.height;
     bg.x = 0
     bg.y = 0

// the regristtration point of your mask should be aligned with the regirstrationpoint of your bg otherwise you have to calculate relative nullpoint

pa-pavelAuthor
Inspiring
February 3, 2014

Worked like a charm! Thx!