Actually, preventDefault() does NOT prevent other listeners from executing; 
this is what stopPropagation() and stopImmediatePropagation() do.
 
preventDefault() simply sets the flag returned by isDefaultPrevented() to be 
true. However, some event-dispatching code in the Player or the framework is 
written like this (and you can do the same thing in your apps):
 
    dispatchEvent(event);
    if (!event.isDefaultPrevented())
        doSomethingByDefault();
 
So calling preventDefault() prevents doSomethingByDefault() from being 
executed. But doSomethingByDefault() is not a listener.
 
- Gordon

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Danko 
Kozar
Sent: Friday, March 09, 2007 1:52 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Are other developers hesitant to extend existing 
classes in Flex?



Jason, this was an eye-opener!
Till now I didn't realize that an event listener can cancel another 
listeners. But the "preventDefault()" method of the Event class does 
exactly that.

This is the way I should go with a PagableGrid.

Thanks!

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
"Jason Hawryluk" <[EMAIL PROTECTED]> wrote:
>
> As a follow up to the last response, take note of the
> event.preventDefault(); in the handler for HEADER_RELEASE, and the 
fact that
> I don't do a refresh on the ListCollectionView after adding the
> 
> sort to it.
> 
> jason
> 
> 
> 
> 
> 
> -----Message d'origine-----
> De : flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>  
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ]De la
> part de Danko Kozar
> Envoyé : jeudi 8 mars 2007 11:48
> À : flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Objet : [flexcoders] Re: Are other developers hesitant to extend 
existing
> classes in Flex?
> 
> 
> Private methods and variables drive me nuts..
> 
> For example, I'd like to make a simple DataGrid change: make 
headers
> clickable without refreshing the grid (just toggle a sort icon).
> (I need this behaviour because I'd like to have a paging DataGrid
> which only propagates the sort column/direction info to a record-
> feching routine on a server)
> 
> So, I try to remove a "collection.refresh();" line from
> the "sortByColumn()" function, but I can't - because it's 
private.
> 
> Then, I try to make a new function called "sortByColumn2" 
(that's a
> copy of the first one, but without "refresh" stuff) and alter
> the "headerReleaseHandler" which calls it, but I can't - cause 
it's
> private.
> 
> And finally, I am trying to add the following code to the
> constructor (yes, the constructor is public, huh.. :-))
> to "neutralize" the event listener:
> 
> removeEventListener(DataGridEvent.HEADER_RELEASE,
> headerReleaseHandler,
> false, EventPriority.DEFAULT_HANDLER);
> 
> ... but I can't cause "headerReleaseHandler" is private and 
can't be
> seen from a subclass!
> 
> And then, I give up.. :-)
> 
> My conclussion is that Flex framework classes are not extensible
> enough and I really can't see a reason.
> Copying the whole DataGrid class and it's renderer, style, etc.
> classes isn't a solution, we all agree. If not other reason - 
it's
> not the OOP way.
> 
> So, I'm tempted to go to a "C:\Program Files\Adobe\Flex Builder 2
> \Flex SDK 2\frameworks\source\mx\" folder and make a global 
search
> and replace on all files in this folder. You guess...
> replace "private" with "protected"... :-)
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> "Dana Gutride" <dgutride@>
> wrote:
> >
> > Recently on this list, somebody said that the Flex framework 
team
> has been
> > surprised at the resistance many developers have to subclassing
> and they'd
> > like to understand it better. I'd like to put my 2 cents into 
this
> > discussion because maybe we can come up with some good answers.
> >
> > I think the ability to extend the existing framework is 
fabulous,
> but I find
> > that I am hesitant to subclass or extend the existing classes.
> Recently, I
> > spent several days trying to override the placeSortArrow 
function
> on the
> > datagrid. I ended up ditching my code because there were so 
many
> private
> > variables used by the existing placeSortArrow() function that I
> would need
> > to rewrite most of the datagrid.as file.
> >
> > I've bought books and searched online for answers, but I 
haven't
> found
> > anything satisfactory yet. Maybe if there were more resources
> (even if we
> > had to pay for them), we would find more developers extending 
the
> flex
> > framework.
> >
> > Dana
> >
>



 

Reply via email to