--- In [email protected], "netdeep" <[EMAIL PROTECTED]> wrote:
>
> Thanks for the reply Todd.  What about processing the event 
though?  For example if I 
> have:
> 
> foo.addEventListener(MouseEvent.MOUSE_DOWN, processResult);
> 
> But I want to define processResult so that I can pass it a number 
or an object, how do I 
> use Custom events?  The even I'm want to listen for is the moue 
down event.  When I 
> define this listener, I know the value I want to associate with 
that event.  Later on, I won't 
> know it so that when processResult gets called, it needs that extra 
parameter to work.  I'm 
> a bit confused about how to use the custom event there, since I 
won't be the one 
> dispatching it.

OK, say that whatever the mouse is down on is a child of an 
itemRenderer that is representing an XML data source, and you want to 
get the node index of the XML node that is being represented.

private function myMouseDownListener(e:event):void{
   //assume for simplicity we know what was clicked
   //is always going to be a direct child of the renderer
   var parent:* = e.target.parent;
   var d:XML = parent.data;
   var nodeNum:int = d.childIndex();
}

Depending on what you are trying to do, you can usually extrapolate 
from the target of the event to what you need to know using the 
parent or the owner chain.

However, if you really feel the need to go with custom events, this 
is a good article I have found helpful:

http://www.adobe.com/devnet/flex/articles/graduating_pt2.html

HTH;

Amy

Reply via email to