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>
转自:http://www.cnblogs.com/taobataoma/archive/2008/08/28/1278192.html

相关文章:

  • 2021-12-20
  • 2021-07-02
  • 2022-01-07
  • 2022-02-14
  • 2021-09-10
  • 2021-11-27
  • 2021-08-26
  • 2021-06-14
猜你喜欢
  • 2022-01-29
  • 2022-03-01
  • 2021-09-30
  • 2021-10-31
  • 2021-11-10
  • 2022-01-24
  • 2021-12-06
相关资源
相似解决方案