<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 沙漠中的魚 閱讀(683) 評論(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

    主站蜘蛛池模板: 日韩一级在线播放免费观看| 成年人性生活免费视频| 亚洲精品亚洲人成在线观看下载 | 好男人资源在线WWW免费| 在线免费不卡视频| 亚洲人成电影网站免费| 免费理论片51人人看电影| 亚洲色大成WWW亚洲女子| 免费观看a级毛片| 精品成人一区二区三区免费视频| 免费一级国产生活片| 国产精品午夜免费观看网站| 亚洲精品无码久久千人斩| 黄色片免费在线观看| 亚洲精品高清国产麻豆专区| 毛片免费vip会员在线看| 国产亚洲精品仙踪林在线播放| 亚洲精品视频免费观看| 在线看片免费人成视频播| 精品国产免费一区二区| 麻豆亚洲AV成人无码久久精品 | 国产免费人成在线视频| 一级黄色免费大片| 亚洲第一中文字幕| 亚洲欧洲免费无码| 黄色毛片免费网站| 亚洲国产女人aaa毛片在线| 在线天堂免费观看.WWW| 色婷婷精品免费视频| 亚洲成年轻人电影网站www | a级片免费在线播放| 亚洲成人福利在线| 国产18禁黄网站免费观看| 任你躁在线精品免费| 亚洲91精品麻豆国产系列在线 | 亚洲精品国产成人专区| 女人与禽交视频免费看| 久久国产精品免费一区| jlzzjlzz亚洲jzjzjz| 国产亚洲欧洲Aⅴ综合一区| 亚洲精品免费网站|