<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    沙漠中的魚

    欲上天堂,先下地獄
    posts - 0, comments - 56, trackbacks - 0, articles - 119
      BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

    手動觸發事件

    Posted on 2008-10-28 11:57 沙漠中的魚 閱讀(686) 評論(0)  編輯  收藏 所屬分類: Flex

    You can manually dispatch events using a component instance's dispatchEvent() method. All components that extend UIComponent have this method. The method is inherited from the EventDispatcher class, which UIComponent extends.

    The syntax for the dispatchEvent() method is as follows:

    objectInstance.dispatchEvent(event:Event):Boolean
    

    When dispatching an event, you must create a new Event object. The syntax for the Event object constructor is as follows:

    Event(event_type:String, bubbles:Boolean, cancelable:Boolean)
    

    The event_type parameter is the type property of the Event object. The bubbles and cancelable parameters are optional and both default to false. For information on bubbling and capturing, see Event propagation.

    You can use the dispatchEvent() method to dispatch any event you want, not just a custom event. You can dispatch a Button control's click event, even though the user did not click a Button control, as in the following example:

    <?xml version="1.0"?>
    <!-- events/DispatchEventExample.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="createListener(event);">
        
    <mx:Script><![CDATA[
            import mx.controls.Alert;
            private function createListener(e:Event):void {
                b1.addEventListener(MouseEvent.MOUSE_OVER, myEventHandler);
                b1.addEventListener(MouseEvent.CLICK, myClickHandler);
            }

            private function myEventHandler(e:Event):void {
                var result:Boolean = b1.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false));           
            }

            private function myClickHandler(e:Event):void {
                Alert.show("The event dispatched by the MOUSE_OVER was of type '" + e.type + "'.");
            }
        
    ]]></mx:Script>

        
    <mx:Button id="b1" label="Click Me"/>

    </mx:Application>

     

    You can also manually dispatch an event in an MXML tag. In the following example, moving the mouse pointer over the button triggers the button's click event:

     

    <?xml version="1.0"?>
    <!-- events/DispatchEventExampleInline.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="createListener(event);">
        
    <mx:Script><![CDATA[
            import mx.controls.Alert;

            private function createListener(e:Event):void {
                b1.addEventListener(MouseEvent.CLICK, myClickHandler);
            }

            private function myClickHandler(e:Event):void {
                Alert.show("The event dispatched by the MOUSE_OVER was of type '" + e.type + "'.");
            }
        
    ]]></mx:Script>

        
    <mx:Button id="b1" 
            label
    ="Click Me" 
            mouseOver
    ="b1.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false));"
        
    />

    </mx:Application>

     

    轉載:http://livedocs.adobe.com/flex/3/html/events_07.html#220526

    主站蜘蛛池模板: 亚洲国产婷婷综合在线精品| 最近中文字幕完整免费视频ww| 在线观看特色大片免费视频| 亚洲黄色网址大全| 国产精品免费观看调教网| 中文字幕亚洲日韩无线码| 中文字幕永久免费| 亚洲精品乱码久久久久久中文字幕 | 国产成人在线观看免费网站| 亚洲卡一卡二卡乱码新区| 综合在线免费视频| 国产v亚洲v天堂a无| 精品国产一区二区三区免费看| 亚洲国产成人久久综合| 免费人成在线观看网站品爱网日本| 久久精品国产亚洲av瑜伽| 免费一级成人毛片| 国产成人无码免费看片软件| 亚洲精品国产品国语在线| 免费国产午夜高清在线视频| 亚洲午夜视频在线观看| 久久久久久国产a免费观看黄色大片| 亚洲av专区无码观看精品天堂| 看全色黄大色大片免费久久| 国产精品亚洲综合| 亚洲欧洲日产国码无码久久99| 免费在线看黄网站| 亚洲一区二区三区无码国产| 免费看少妇作爱视频| 人人公开免费超级碰碰碰视频| 亚洲国产a∨无码中文777| 国产91色综合久久免费| 亚洲变态另类一区二区三区| 亚洲欧洲国产成人综合在线观看| 中国一级毛片视频免费看| 亚洲国产精品日韩在线| 国产精品久久久久影院免费| 99视频在线观看免费| 在线aⅴ亚洲中文字幕| 亚洲欧洲日产国码一级毛片 | 一道本在线免费视频|