/ Published in: ActionScript 3
Expand |
Embed | Plain Text
// STEP 1 // Create _contentWidth and _contentHeight as private vars to store the initial _content dimensions. _contentWidth = _content.width; _contentHeight = _content.height; // STEP 2 // In your resize handler, use the following code: var scale:Number = 1; if ( _contentWidth < stage.stageWidth || _contentHeight < stage.stageHeight ) { scale = Math.max( stage.stageHeight / _contentHeight, stage.stageWidth / _contentWidth ); } // STEP 3 // To apply the calculated scale, use: _content.width = _contentWidth * scale; _content.height = _contentHeight * scale;
Comments
Subscribe to comments
You need to login to post a comment.

This seems to have a problem with the width and height of masked content.
Any ideas how to work around this?
i've found that masks screw up the width and height properties. you could override public function get width():Number and height():Number inside the object you're scaling, or use separate properties to store the correct dimensions