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" ?>
<!--  http://blog.flexexamples.com/2008/03/21/creating-an-undraggable-alert-control-in-flex/  -->
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white" >

    
< mx:Script >
        
<![CDATA[
            import mx.controls.Alert;

            private function draggableAlert():void {
                Alert.show("Drag me!");
            }

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

            private function alert_mouseDown(evt:MouseEvent):void {
                evt.stopImmediatePropagation();
            }
        
]]>
    
</ mx:Script >

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

</ mx:Application >
复制代码
相关文章
|
23天前
|
容器
Bootstrap5 Flex(弹性)布局4
排序:.order 类可设置弹性子元素的排序,范围从 .order-1 至 .order-12,数字越小优先级越高。外边距:.ms-auto 和 .me-auto 分别用于设置子元素的右侧和左侧外边距为 auto。包裹:.flex-nowrap(默认)、.flex-wrap 和 .flex-wrap-reverse 用于控制弹性容器中的子元素是否换行及换行方向。