Flex - Alert창 아이콘 변경(버튼크기, 메시지 이상)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="vertical" backgroundGradientColors="[#ffffff, #c0c0c0]" >
 <mx:Style>
  global {
            modalTransparencyBlur: 0;
            modalTransparency: 0.8;
            modalTransparencyColor: black;
            modalTransparencyDuration: 500;
        }
        /* 버튼 스타일 */
  .roundedAlertButtons {
            cornerRadius: 10;
            fontWeight: bold;
            color: black;
           
        }
        /* Alert메시지  스타일 */
        .alertMessageStyle{         
         fontSize: 15;
            fontWeight: bold;
            color: yellow;
        }
        /* Alert 스타일*/     
        Alert{
   messageStyleName : "alertMessageStyle";
   buttonStyleName : "roundedAlertButtons";
   backgroundColor : "0xffffff";
   backgroundAlpha : "0.50";
   borderColor : "0xffffff";
   borderAlpha : "0.75";    
  }  </mx:Style>
 <mx:Script>
  <![CDATA[
   import mx.events.CloseEvent;
   import mx.controls.Alert;  

   [Embed(source='assets/warning2.png')]
   private var confirmIcon:Class;
   
   private function confirm():void{
   
    Alert.buttonWidth = 120;
    Alert.yesLabel = "오~예";
    Alert.noLabel = "오~노";
    Alert.cancelLabel = "오~캔슬?";
   
    var alert:Alert = Alert.show(msg,
     "경고!!!",
     Alert.YES|Alert.NO|Alert.CANCEL,
     this,
     confirmHandler,
     confirmIcon,
     Alert.YES);
   
    /* alert.setStyle("backgroundColor", 0xffffff);
    alert.setStyle("backgroundAlpha", 0.50);
    alert.setStyle("borderColor", 0xffffff);
    alert.setStyle("borderAlpha", 0.75);    
    alert.setStyle("buttonStyleName", "roundedAlertButtons");
    alert.setStyle("messageStyleName", "alertMessageStyle");    
    alert.width = 800;
    alert.height = 400;    */
     
   }
   
   private function confirmHandler(event:CloseEvent):void{
    mx.controls.Alert.show("클릭?!");
   }
  ]]>
 </mx:Script>
 <mx:String id="msg">Alert창의 아이콘을  변경하였습니다. 오케이? </mx:String>
 <mx:Button label="Alert창 띄우기" fontSize="12" click="confirm()" />  
</mx:Application>

alert 창 아이콘 변경할때
글쓴 부분의 width, height 는 어떻게 하는건지..  - alert창의 width, height는 변경 가능하다
버튼의 width, height 는 어떻게 하는건지.. - 기본 Alert창의 buttonWidth, buttonHeight는 변경 가능하다.

일단, 버튼
버튼안의 글자가 길어지다보니 '...' 으로 표시가 된다.
그래서 버튼 크기를 늘리려고 했는데 Alert.buttonWidth 값을 주는데 현재 내가 아이콘을 변경한
alert의 버튼 크기는 커지지않고, confirmHandler 부분의 Alert창의 버튼 크기만 커지는 현상이 발생되었다.
왜?왜?왜?
스타일에도 줘보고 별짓 해봤는데 안되서.. 흠...
결국 해결은 했다.. 근데 그때의 내 심정은..

Alert.buttonWidth 의 소스상의 위치문제였다.

var alert:Alert = Alert.show(...
여기서 alert를 생성하는 것 보다 위에 위치해야 한다.

Alert.buttonWidth = 120;
Alert.yesLabel = "오~예";
Alert.noLabel = "오~노";
Alert.cancelLabel = "오~캔슬?";

이 부분 모두..
alert 생성한 것보다 아래에 위치하면 적용되지 않는다. 으~

이제 글자(메시지 부분)
더 이상했다. 글자가 짤렸다. 옆으로 마우스로 드래그하면 나머지 글자가 보였다.
그래서 alert.width 의 값을 더 늘려줬다.
창은 커졌는데 글자가 짤리는 건 그대로였다.
해결은 했는데 좀 찜찜하긴 하다.
스타일을 Alert의 스타일로 다시 정의했다.
왜그런지 누가 이유좀 가르쳐주시길...

'Java&Flex' 카테고리의 다른 글

FCKeditor 사용기  (0) 2008.09.25
플렉스 빌더 3 + LiveCycle Data Services ES Express(lcds) 설치  (0) 2008.09.04
Flex Explorer  (0) 2008.08.28
Java - 1  (0) 2007.10.25
자바 시작  (2) 2007.10.25