The Flex AlertTimer component displays a pop up alert window which automatically closes and displays a countdown timer to the user.
Click here to view an example
(right click application to view source)
The alert can be called from a 'show' method which accepts the following properties:
- parent:DisplayObject = The component the alert displays over most likely the parent application
- alertText:String = The message to display in the alert window
- alertTitle:String = The title of the alert popup
- modal:Boolean = If true the user will not be able to interact with the rest of the application until the alert closes
var myAlert:AlertTimer = new AlertTimer();
myAlert.show(this, "my alert message", "my alert title", true);
You can further customize the AlertTimer by setting more properties.
var myAlert:AlertTimer = new AlertTimer();
myAlert.duration = 10;
myAlert.buttonText = "Click here to close now";
myAlert.alertWidth = 200;
myAlert.counterText = "This window will self destruct in ";
myAlert.show(this, "my alert message", "my alert title", true);
While this component serves my purpose just fine it can certainly be expanded upon to include the full set of features available in a regular Flex Alert. For starters I'm pretty new to ActionScript and Flex so I wasn't able to figure out how to actually extend the current Alert class. So instead I just created my own component and therefore their isn't the ability to use multiple buttons like you can with an Alert. That said, if you were going to use multiple buttons you may not want to automatically close the alert on a timer.
I do realize that you can easily close a regular alert using the setTimeout() function and the PopUpManager, but then you can't display a dynamic countdown which I think is more user friendly.
No comments:
Post a Comment
Thank you for the comments.