<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 :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

    手動觸發(fā)事件

    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

    主站蜘蛛池模板: 国产大片91精品免费看3 | 国产午夜亚洲精品| 国产啪精品视频网免费| 亚洲欧洲无码AV电影在线观看 | 亚洲自偷自偷偷色无码中文| 看免费毛片天天看| 亚洲AV中文无码乱人伦在线视色| 国产精品亚洲五月天高清| 免费一级肉体全黄毛片| 日本特黄特色AAA大片免费| 亚洲成a人片在线观看久| 一区二区三区视频免费观看| 不卡一卡二卡三亚洲| 免费精品久久天干天干| 色婷婷亚洲十月十月色天| 无码国产精品一区二区免费虚拟VR| 亚洲av成人一区二区三区| 香蕉高清免费永久在线视频 | 成人免费视频小说| 亚洲a∨无码精品色午夜| 亚洲AV无码乱码在线观看性色扶| CAOPORM国产精品视频免费| 久久精品国产亚洲av影院| 精品久久免费视频| www.亚洲色图| 两个人看的www高清免费观看| 免费看一区二区三区四区| 亚洲国产精品成人久久蜜臀| 人体大胆做受免费视频| 成熟女人特级毛片www免费| 久久乐国产综合亚洲精品| 在线永久免费观看黄网站| 51午夜精品免费视频| 亚洲综合婷婷久久| 免费的一级黄色片| 国产午夜精品理论片免费观看 | 亚洲美女中文字幕| 在线免费观看一级片| 九九久久精品国产免费看小说| 亚洲高清在线观看| 成人免费毛片观看|