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

    主站蜘蛛池模板: 亚洲AV成人片无码网站| 亚洲av片在线观看| 午夜成年女人毛片免费观看| 亚洲爆乳成av人在线视菜奈实 | 亚洲狠狠婷婷综合久久久久| 久久99国产乱子伦精品免费| 亚洲一线产品二线产品| 国产亚洲美女精品久久久2020| 亚洲美女免费视频| 九九视频高清视频免费观看| 亚洲黄色在线播放| 亚洲?V无码乱码国产精品 | 免费在线观看一级毛片| 三年片在线观看免费观看大全一 | 亚洲精品天堂成人片?V在线播放| 亚洲欧洲免费视频| 一级人做人爰a全过程免费视频| 亚洲天堂一区二区三区| 久久久久亚洲av毛片大 | 亚洲电影在线播放| 久久久久亚洲AV无码专区桃色 | 777亚洲精品乱码久久久久久| 国产午夜无码视频免费网站| 91成人在线免费视频| xxxxx做受大片视频免费| 国产成人亚洲综合一区| 久久亚洲AV午夜福利精品一区| 免费日韩在线视频| 九九九精品成人免费视频| 暖暖日本免费中文字幕| 免费无毒a网站在线观看| 亚洲午夜成人精品无码色欲| 亚洲精品国产成人专区| 在线A亚洲老鸭窝天堂| 亚洲av日韩片在线观看| 岛国片在线免费观看| 亚洲国产精品免费观看| 99精品视频在线观看免费专区| 久久精品免费网站网| 美女黄网站人色视频免费| 亚洲av综合av一区二区三区|