Friday, September 9, 2011

Handeling text overflow in Flex Alert

//your code//
var a:Alert = Alert.show("..long..text....");
handelOverFlow(a,500);
private function handelOverFlow(alert:Alert,maxHeight:int):void {
   var array:Array = alert.getChildren();
   var uiCom:UIComponent = array[0];
   var txtField:UITextField = uiCom.getChildAt(0) as UITextField;
   var box:Box = new Box();
   //if AlertForm (uiCom) has more height then desired height
   if(uiCom.height>maxHeight) {
     uiCom.height = maxHeight;
     txtField.parent.removeChild(txtField);;
     box.width = uiCom.width;
     box.height = maxHeight - 50;
     box.addChild(txtField);
     uiCom.addChildAt(box,0);
  }
}

No comments:

Post a Comment