Tuesday, May 11, 2010

Move Flex Alert.show on the screen

I have a tall Flex application that uses Alert.show( ) to display error messages.  This created problems when the error messages were centered on the screen, but not visible when the screen was at an extreme scroll position (top or bottom).  To solve this, I capture the MouseEvent and use it to set the Alert’s “Y” position.  Note this code did not work UNTIL I used the PopUpManager.centerPopUp prior to moving:


var errorMsg:Alert = Alert.show(errmsg,"Error", Alert.OK, this);



var mousePt:Point = new Point(event.localX, event.localY);

mousePt = event.target.localToGlobal(mousePt);

errorMsg.move(errorMsg.x, mousePt.y - 50); // try to vertical center it at button

No comments: