Re: [Flashcoders] proportional image/clip scaling
Here are two functions I just copied from a class of mine: _nScale is the scale it will be, assuming that a perfect fit to the container box is 100%. nLPW - is the width of the container box nLPH - is the height of the container box the code also centers the mc to the box. private function resize(mc:MovieClip):Void { mc._xscale = mc._yscale = 100; var nRatio:Number = 0; if (isWider(mc)) { nRatio = _nLPW / mc._width; } else { nRatio = _nLPH / mc._height; } mc._xscale = mc._yscale = nRatio * _nScale; mc._x = _nLPW / 2 - mc._width / 2; mc._y = _nLPH / 2 - mc._height / 2; } private function isWider(mc:MovieClip):Boolean { var nProportionPhoto:Number = mc._width / mc._height; var nProportionBox:Number = _nLPW / _nLPH; return nProportionPhoto > nProportionBox; } On 3/21/06, Alan Queen <[EMAIL PROTECTED]> wrote: > anybody have the math handy to proportionally scale one clip to another? > > Meaning, let's say I load in an image that is 100w - 300h. > > and I want to display it in an area that is 320w - 240h. > > So I want to scale the original image clip to fit within the display > area, but show the entire image. > > -- > - Alan Queen > ___ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > -- Ramon Miguel M. Tayag Managing Director Quirkworks ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] proportional image/clip scaling
This is a very old function and needs tidying up but I tink it should help public function getScaleToFit(mcChild:MovieClip,intHeight:Number,intWidth:Number, blnOver100:Boolean):Number{ var intScale:Number = 100; if(intHeight == undefined){intHeight = _root._height;} if(intWidth == undefined){intWidth = _root._width;} if(blnOver100 == undefined){blnOver100 = false;} while((mcChild._height/100)*intScale > (intHeight)){ intScale--; } while((mcChild._width/100)*intScale > (intWidth)){ intScale--; } if((intScale == 100) && blnOver100){ while((mcChild._height/100)*intScale < (intHeight)){ intScale++; } while((mcChild._width/100)*intScale < (intWidth)){ intScale++; } intScale--; } return intScale; } Jim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alan Queen Sent: 20 March 2006 23:07 To: Flashcoders mailing list Subject: [Flashcoders] proportional image/clip scaling anybody have the math handy to proportionally scale one clip to another? Meaning, let's say I load in an image that is 100w - 300h. and I want to display it in an area that is 320w - 240h. So I want to scale the original image clip to fit within the display area, but show the entire image. -- - Alan Queen ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] proportional image/clip scaling
anybody have the math handy to proportionally scale one clip to another? Meaning, let's say I load in an image that is 100w - 300h. and I want to display it in an area that is 320w - 240h. So I want to scale the original image clip to fit within the display area, but show the entire image. -- - Alan Queen ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com