Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AIR Android fullscreen masked background -- plz help

Explorer ,
Feb 03, 2014 Feb 03, 2014

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

TOPICS
ActionScript
656
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Feb 03, 2014 Feb 03, 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 ot

...
Translate
Guru ,
Feb 03, 2014 Feb 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 03, 2014 Feb 03, 2014
LATEST

Worked like a charm! Thx!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines