Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Worked like a charm! Thx!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now