MovieClip.prototype.fitToArea = function(width:Number, height:Number, type:String) : Object { // Returns the correct width and height values outside of a given size. if (type == "outside" || type == undefined) { if ((width / height) > (this._width / this._height)) { var new_width:Number = this._width / (this._width / width); var new_height:Number = this._height / (this._width / width); } else { var new_width:Number = this._width / (this._height / height); var new_height:Number = this._height / (this._height / height); } } if (type == "inside") { if ((width / height) < (this._width / this._height)) { var new_width:Number = this._width / (this._width / width); var new_height:Number = this._height / (this._width / width); } else { var new_width:Number = this._width / (this._height / height); var new_height:Number = this._height / (this._height / height); } } return {width: new_width, height: new_height}; };