/ Published in: ActionScript 3

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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
