Flex 컴포넌트의 비율 유지
개발/FLEX & AIR2009. 12. 21. 15:33
<?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="50%" height="50%"/>
</mx:Application>
<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="50%" height="50%"/>
</mx:Application>
'개발 > FLEX & AIR' 카테고리의 다른 글
Flex 흐르는 텍스트 효과 (0) | 2010.01.12 |
---|---|
[Caster] XML만을 사용시 서버측 XML 객체 상호변환 (0) | 2009.12.24 |
Flex와 Java간 소켓 통신 (1) | 2009.12.21 |
XML과 E4X 다루기 (0) | 2009.12.20 |
[Flex] PieChart (0) | 2009.11.24 |