简体   繁体   中英

See the event listeners in Flex/Flash builder debug

Do anyone know how to see the event listeners of any component in the debug mode of the Flex or Flash builder?

Cheers,PK

There is no straightfoward way to enumerate listeners AFAIK.

You can still do what you would usually have to do with methods from the IEventDispatcher interface:

package flash.events
{
    public interface IEventDispatcher
    {
        function addEventListener(eventName:String, 
                        listener:Object,
                        useCapture:Boolean=false,
                        priority:Integer=0,
                            useWeakReference:Boolean=false):Boolean;

        function removeEventListener(eventName:String, 
                    listener:Object,
                    useCapture:Boolean=false):Boolean;

        function dispatchEvent(eventObject:Event):Boolean;

        function hasEventListener(eventName:String):Boolean;
        function willTrigger(eventName:String):Boolean;
    }
}

Source of the above code: http://livedocs.adobe.com/flex/3/html/help.html?content=16_Event_handling_6.html

create a variable on the class called:

private var __numListeners:Number=0;

then create a set and get method to edit that variable... and each time a listener is added or removed it adjusts that var using that method...

this.setNumListeners(1); or whatever

then it can be accessed through a

trace(someObject.getNumListeners())

There is no quick way to do this without editing all of the components in your app that implement the IEventDispatcher interface.

If the player was open source then you could extend the EventDispatcher class to add trace statements into it, but it isn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM