Creating an undraggable Alert control in Flex

The following example shows how you can create a Flex Alert control that isn’t draggable by listening for the mouseDown event and calling the stopImmediatePropagation() method in the event handler.

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application xmlns:mx=""

            import mx.controls.Alert;

            private function draggableAlert():void {
      "Drag me!");

            private function undraggableAlert():void {
                var alert:Alert ="Drag me!");
                alert.addEventListener(MouseEvent.MOUSE_DOWN, alert_mouseDown, true);

            private function alert_mouseDown(evt:MouseEvent):void {

    <mx:ApplicationControlBar dock="true">
        <mx:Button label="Draggable Alert"
                click="draggableAlert();" />
        <mx:Button label="Undraggable Alert"
                click="undraggableAlert();" />


View source is enabled in the following example.

For another example of creating an undraggable Flex Alert control, see Creating an undraggable Alert control in Flex (redux).

One thought on “Creating an undraggable Alert control in Flex

  1. This is incredibly userful, for many other situations as well.
    Preventing the propagation of an event, or at least sometimes it’s default behaviour ( is a really nice tip.

    Thanks again!

Comments are closed.