컴포넌트의 비율을 유지하려면 ==> updateDisplay를 유심하게 관찰하면 됨.


<?xml version="1.0" encoding="utf-8"?>

<mx:Application

       verticalAlign="middle" horizontalAlign="center"

       paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0"

       xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

       <mx:Script>

             <![CDATA[

                    private const ratio:Number = .75;

                   

                    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{

                           super.updateDisplayList(unscaledWidth,unscaledHeight);

                           btn.width = unscaledWidth;

                           btn.height = unscaledHeight;

                           var tmpRatio:Number = btn.height / btn.width;

                           if(tmpRatio>ratio){

                                 btn.height = btn.width * ratio;

                           }else{

                                 btn.width = btn.height / ratio;                                                       

                           }                         

                    }

             ]]>

       </mx:Script>

       <mx:Button id="btn" width="100%" height="100%"/>

</mx:Application>

+ Recent posts