Sorry, read the code incorrectly.  Thought he was modifying the event
properties.  Modifying a property on the object is "ok" until you have
two listeners both trying to set that property.

 

Events are really for notification, and notifications aren't really
supposed to answer any other question than "that's (not) ok with me".
The cancelable/preventDefault() mechanism is used for that, and
propagation control is used to block notification.

 

That's not to say I'm one of the strict-minded folks.  I've definitely
found scenarios where I would want to  modify the payload of an event.
Even though it disturbs our more strict-minded developers, passing a
reference to a mutable object is sort of a token-passing behavior where
listeners get to modify it as it goes around, but in the order of
propagation.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Andrews
Sent: Tuesday, March 25, 2008 12:43 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Can a Listener return a value

 

----- Original Message ----- 

        From: Alex Harui <mailto:[EMAIL PROTECTED]>  

        To: flexcoders@yahoogroups.com
<mailto:flexcoders@yahoogroups.com>  

        Sent: Tuesday, March 25, 2008 6:49 PM

        Subject: RE: [flexcoders] Can a Listener return a value

         

        That works, but is considered a "hack" in the strictest sense.
The W3C Events spec indicates that event properties are read-only.
Flash allows writing to them to make setup easier (constructor args are
easy to mix up).

         

Hmm. In this sense, surely event.target is a reference to an object, so
really this has nothing to do with event properties at all? (it's just
using the object reference to set a public attribute). Or are you
referring to the lack of a cast -
SomeClass(event.target).publicParameter ?

 

Of course the listener could also call a callback method -
SomeClass(event.target).aCallbackFn() .

 

Paul

         

        
________________________________


        From: flexcoders@yahoogroups.com
<mailto:flexcoders@yahoogroups.com>  [mailto:[EMAIL PROTECTED]
On Behalf Of Mike Krotscheck
        Sent: Tuesday, March 25, 2008 11:34 AM
        To: flexcoders@yahoogroups.com
        Subject: RE: [flexcoders] Can a Listener return a value

         

        foo.addEventListener( Event.SomeEvent, responderEventHandler );

         

        private function responderEventHandler(event:Event):void

        {

                    event.target.publicParameter = "bar";

        }

         

        Michael Krotscheck

        Senior Developer

        


        RESOURCE INTERACTIVE

        <http://www.resource.com/> www.resource.com
<http://www.resource.com> 

        [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 

        
________________________________________________________________________
_______
        
        We support privacy and confidentiality. Please delete this email
if it was received in error.
        
        
        What's new ::
        
        Capitalize on the social web | The Open Brand, a new book by
Kelly Mooney and Dr. Nita Rollins, available March 2008 |
www.theopenbrand.com

        
________________________________


        From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of markgoldin_2000
        Sent: Tuesday, March 25, 2008 1:31 PM
        To: flexcoders@yahoogroups.com
        Subject: [flexcoders] Can a Listener return a value

         

        Can a Listener program return a value back to a program that set
this 
        listener up?
        
        Thanks

 

Reply via email to