Here's an example of what I meant: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ private var foo:int = 7; private function clickHandler(event:MouseEvent):void { trace(foo); } ]]> </mx:Script> <mx:Button click="clickHandler(event)"/> </mx:Application>
Note that the Button's clickHandler() can access the instance variable 'foo', despite the fact that 'foo' isn't passed to clickHandler() and 'foo' isn't a property of event.target, which is the Button. The reason that clickHandler() can access 'foo' is that when clickHandler() executes, 'this' is the Application (or whatever component you're writing). - Gordon ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of darylgmyers Sent: Wednesday, February 14, 2007 7:42 AM To: [email protected] Subject: [flexcoders] Re: addEventListener and additional arguments? Gordon, I'm pretty new to Flex so I appologize for the additional question. Are you saying that I can add an instance property to the target so that it will be available in the event.target? What I'm actually doing is creating a set of form fields on the fly using action script. Some of these fields may be number types with a precision value. My formatting is done with an event listener which I need to be able to pass the precision value. --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > There should be no need to pass additional arguments to the event > handler method, because -- assuming it is indeed a method of a class -- > it can access all the instance properties of that class. So just set an > instance property. > > - Gordon > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of darylgmyers > Sent: Tuesday, February 13, 2007 1:42 PM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] addEventListener and additional arguments? > > > > Is there a way to use the addEventListener method and pass additional > arguments along with the event? I have a form where I must create the > form objects dynamically so I need to use addEventListener for > formatting, etc. I can not use inline mxml to add the listeners. >

