开发者

How Do I See All Events Fired by an Object?

I am having trouble wiring up an event listener to a fl.transitions.Transition.

Is it possible to somehow view all the events an object fires? That way I could check开发者_运维技巧 I am using the correct event (and possible view better ones to use).


The easiest is to override the dispatchEvent method in classes where you want to intercept events.
You can find the classes in %CS_ROOT%\Common\First Run\Classes\mx\transitions\easing\.

You can also create a subclass of EventDispatcher with a custom dispatchEvent-implementation and use that as a subclass for all classes where you'll be wanting to intercept events.

greetz
back2dos


The problem is, you have to have an event type to listen for. The only way to do this is to add listeners for all the possible events.

Now, you can add a handler with an indeterminate event type, such as:

private function myUniversalHandler(event:*) : void {
  trace(event.type);
  trace(event.constructor.toString());
}

And this will report any event passed to it. Nevertheless, it simply won't be called unless it is listening for an event of a particular type. And adding all those listeners is a lot of work to go through. Better to study the events available to you from whatever class you are dispatching the vent from.


I would look at TransitionManager, and the events allTransitionsOutDone and allTransitionsInDone which it dispatches. I haven't used these, but my understanding of their function matches what you seem to be looking for.


checkout the online reference, you should see there all events (and inherited events) of a Class.
On a side note if you are using flex you might be using mx.states.Transition


There is no way, at runtime, to find out all the events that fire from a component. You'll have to explore the component source code to get a complete list.

Reviewing the ASDocs, as others have suggested, is a good way to get a handle on the documented events of a component; and in most cases you'll be able to find one to suit your needs.


You cannot programmatically get a list of all events fired by any given object. You can however get a list of all events fired by a standard library object (that are part of it's public interface) from its documentation (cilck on the show inherited events link) and decide whether you're using the appropriate one.


I have scratched my head quite a bit on this issue as well. The answer is this

  1. you can get a list of all event listeners that an object is listening to only if attached though MXML
  2. if not attached through MXML you cannot see the events an object is listening to (attached by AS)

if you want to see all the events an object is listening to you can check for hasEventListener although this is a long coding way

another efficient way (if you can use it, I couldn't) is to monkey patch the framework and create a dictionary of listeners for every object. you can accomplish that by patching FlexSprite and overriding the addEventListener function. you should keep in mind, this will not work when you are loading the framework through RSL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜