You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Mark Kessler <ke...@gmail.com> on 2013/07/17 02:16:38 UTC

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Well I had some old code laying around that did exactly this.  I've
stripped it out and created an example with it [1].  It overrides the
EventDispatcher methods.  I do not plan on checking it into the sdk,
because it has to be duplicating the EventDispatcher's internal arrays.  It
would be better to just put a ticket into Adobe to have some methods /
array's exposed (if they allow it).

But I do plan on ripping the changes out and attaching them to the issue as
a work around before resolving it.  Does anyone have any change/addition
ideas before I do?

I did have a simple serving eventlistener I removed, but it works pretty
good too.


-Mark


On Thu, Jul 11, 2013 at 5:41 AM, Mark Kessler (JIRA) <ji...@apache.org>wrote:

>
>      [
> https://issues.apache.org/jira/browse/FLEX-33608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> Mark Kessler reassigned FLEX-33608:
> -----------------------------------
>
>     Assignee: Mark Kessler
>
> > Add function "removeAllEventListener()"
> > ---------------------------------------
> >
> >                 Key: FLEX-33608
> >                 URL: https://issues.apache.org/jira/browse/FLEX-33608
> >             Project: Apache Flex
> >          Issue Type: New Feature
> >          Components: Spark Components
> >    Affects Versions: Apache Flex 4.9.0
> >            Reporter: Robbyn Gerhardt
> >            Assignee: Mark Kessler
> >              Labels: event, removeEventListener
> >             Fix For: Apache Flex 4.10.0
> >
> >   Original Estimate: 12h
> >  Remaining Estimate: 12h
> >
> > Can you add a function that removes all events of a component?
>
> --
> This message is automatically generated by JIRA.
> If you think it was sent incorrectly, please contact your JIRA
> administrators
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Mark Kessler <ke...@gmail.com>.
Glad I'm using the getItemAt then lol.

Thanks Alex.


On Wed, Jul 17, 2013 at 3:04 AM, Alex Harui <ah...@adobe.com> wrote:

>
>
> On 7/16/13 6:22 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>
> >Hi,
> >
> >> I started using more getItemAt because not everything allows the
> >>brackets anymore.
> >Only in binding expressions I thought?
> >
> >>  Not sure how much of a speed difference there is.
> >Not sure, I'd getItemAt is probably faster but may be so little in it
> >that it's not really a concern.
> I may not understand the context here, but for ArrayCollection, accessing
> items via ac.[index] is much slower than calling ac.getItemAt(index).
> >
>
>

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Mark Kessler <ke...@gmail.com>.
Forgot to put the view source link out for the example app [1]

[1] http://people.apache.org/~mkessler/examples/FLEX-33608/app.mxml.txt



On Tue, Jul 16, 2013 at 9:22 PM, Justin Mclean <ju...@classsoftware.com>wrote:

> Hi,
>
> > I started using more getItemAt because not everything allows the
> brackets anymore.
> Only in binding expressions I thought?
>
> >  Not sure how much of a speed difference there is.
> Not sure, I'd getItemAt is probably faster but may be so little in it that
> it's not really a concern.
>
> Thanks,
> Justin

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Alex Harui <ah...@adobe.com>.

On 7/16/13 6:22 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>> I started using more getItemAt because not everything allows the
>>brackets anymore.
>Only in binding expressions I thought?
>
>>  Not sure how much of a speed difference there is.
>Not sure, I'd getItemAt is probably faster but may be so little in it
>that it's not really a concern.
I may not understand the context here, but for ArrayCollection, accessing
items via ac.[index] is much slower than calling ac.getItemAt(index).
>


Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> I started using more getItemAt because not everything allows the brackets anymore.
Only in binding expressions I thought?

>  Not sure how much of a speed difference there is.
Not sure, I'd getItemAt is probably faster but may be so little in it that it's not really a concern.

Thanks,
Justin

RE: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Kessler CTR Mark J <ma...@usmc.mil>.
Oh wait that was one version of it... here is the newer one [1]

[1] https://github.com/KesslerConsulting/example/blob/master/frameworks/projects/framework/src/mx/core/FlexSprite.as.

-Mark

-----Original Message-----
From: Kessler CTR Mark J [mailto:mark.kessler.ctr@usmc.mil] 
Sent: Monday, July 22, 2013 5:48 AM
To: dev@flex.apache.org
Subject: RE: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"


   Yeah, I went down a rabit hole with mine replacing the whole thing and adding some methods to it.  But if you check [1] for the working code and you can see an example of it [2].  You don't need to apply it to FlexSprite directly, it was just easy to test tons of components at one time.  You can put that overridden code in anything that uses the EventDispatcher.


   The problem with the whole thing is that the EventDispatcher is not in our control.   It's part of flash.events [3].  So what I will do add the code to the issue 33608 and resolve it.  Then once I wrap up my new one, I will prob put that in as a separate file to the SDK so that it's available for people to write custom components and use as an EventDispatcher they have control over.

   The only method I can't seem to complete is the willDispatch method.  It can somehow check if it's children will pass it events that could be triggered.


[1] https://github.com/KesslerConsulting/example/blob/30ee4b96911d301ea09516324241c4bc9d734f16/frameworks/projects/framework/src/mx/core/FlexSprite.as

[2] http://people.apache.org/~mkessler/examples/FLEX-33608/app.swf  (also has view source enabled).

[3] http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/EventDispatcher.html


-Mark

-----Original Message-----
From: jude [mailto:flexcapacitor@gmail.com] 
Sent: Sunday, July 21, 2013 10:52 PM
To: dev@flex.apache.org
Subject: Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Did you find out if this is possible? I've patched FlexSprite with a remove
event listener method but I think that it is causing an issue where my
project (web) doesn't load on any computer except my own. But the reason
it's not loading might be an issue with monkey patching but I haven't found
the cause yet.

Also, you can use,

nLoopingIndex = [1,2,3].length;

for ( ; nLoopingIndex-- ; ) {
    trace(nLoopingIndex);
}

to reverse through a loop when you know the index will always be 0 or
greater.


On Tue, Jul 16, 2013 at 8:16 PM, Mark Kessler
<ke...@gmail.com>wrote:

> Changing the flexsprite wasn't going to get everything.  It was just low
> hanging fruit for a test/example since it allowed me a wide range of
> components to test with.  If I could have changed the EventDispatcher it
> would have been a better :P
>
> I like the looping backwards idea for removing items... will keep me from
> adjusting values as much.  I'll change over to that later.
>
> I started using more getItemAt because not everything allows the brackets
> anymore.  Not sure how much of a speed difference there is.
>
>
> Thanks Justin
>
> -Mark
>
> On Tue, Jul 16, 2013 at 8:41 PM, Justin Mclean <justin@classsoftware.com
> >wrote:
>
> > Hi,
> >
> > >
> >
> https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16
> >
> > Very quick glance, but I think that removing items from a list when
> you're
> > looping to the number of original items in the list can get you into
> > trouble.
> >  for (nLoopingIndex = 0; nLoopingIndex < nListenerTotal; nLoopingIndex++)
> >
> > It's best to loop backwards to avoid this issue. Like so:
> >  for (nLoopingIndex = nListenerTotal -1 ; nLoopingIndex >= 0;
> > nLoopingIndex--)
> >
> > I'd also use bracket notation rather than getItemAt but perhaps that's
> > just me?
> >
> > You might also need to think about stage events and the like.
> >
> > Thanks,
> > Justin
>

RE: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Kessler CTR Mark J <ma...@usmc.mil>.
   Yeah, I went down a rabit hole with mine replacing the whole thing and adding some methods to it.  But if you check [1] for the working code and you can see an example of it [2].  You don't need to apply it to FlexSprite directly, it was just easy to test tons of components at one time.  You can put that overridden code in anything that uses the EventDispatcher.


   The problem with the whole thing is that the EventDispatcher is not in our control.   It's part of flash.events [3].  So what I will do add the code to the issue 33608 and resolve it.  Then once I wrap up my new one, I will prob put that in as a separate file to the SDK so that it's available for people to write custom components and use as an EventDispatcher they have control over.

   The only method I can't seem to complete is the willDispatch method.  It can somehow check if it's children will pass it events that could be triggered.


[1] https://github.com/KesslerConsulting/example/blob/30ee4b96911d301ea09516324241c4bc9d734f16/frameworks/projects/framework/src/mx/core/FlexSprite.as

[2] http://people.apache.org/~mkessler/examples/FLEX-33608/app.swf  (also has view source enabled).

[3] http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/EventDispatcher.html


-Mark

-----Original Message-----
From: jude [mailto:flexcapacitor@gmail.com] 
Sent: Sunday, July 21, 2013 10:52 PM
To: dev@flex.apache.org
Subject: Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Did you find out if this is possible? I've patched FlexSprite with a remove
event listener method but I think that it is causing an issue where my
project (web) doesn't load on any computer except my own. But the reason
it's not loading might be an issue with monkey patching but I haven't found
the cause yet.

Also, you can use,

nLoopingIndex = [1,2,3].length;

for ( ; nLoopingIndex-- ; ) {
    trace(nLoopingIndex);
}

to reverse through a loop when you know the index will always be 0 or
greater.


On Tue, Jul 16, 2013 at 8:16 PM, Mark Kessler
<ke...@gmail.com>wrote:

> Changing the flexsprite wasn't going to get everything.  It was just low
> hanging fruit for a test/example since it allowed me a wide range of
> components to test with.  If I could have changed the EventDispatcher it
> would have been a better :P
>
> I like the looping backwards idea for removing items... will keep me from
> adjusting values as much.  I'll change over to that later.
>
> I started using more getItemAt because not everything allows the brackets
> anymore.  Not sure how much of a speed difference there is.
>
>
> Thanks Justin
>
> -Mark
>
> On Tue, Jul 16, 2013 at 8:41 PM, Justin Mclean <justin@classsoftware.com
> >wrote:
>
> > Hi,
> >
> > >
> >
> https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16
> >
> > Very quick glance, but I think that removing items from a list when
> you're
> > looping to the number of original items in the list can get you into
> > trouble.
> >  for (nLoopingIndex = 0; nLoopingIndex < nListenerTotal; nLoopingIndex++)
> >
> > It's best to loop backwards to avoid this issue. Like so:
> >  for (nLoopingIndex = nListenerTotal -1 ; nLoopingIndex >= 0;
> > nLoopingIndex--)
> >
> > I'd also use bracket notation rather than getItemAt but perhaps that's
> > just me?
> >
> > You might also need to think about stage events and the like.
> >
> > Thanks,
> > Justin
>

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by jude <fl...@gmail.com>.
Did you find out if this is possible? I've patched FlexSprite with a remove
event listener method but I think that it is causing an issue where my
project (web) doesn't load on any computer except my own. But the reason
it's not loading might be an issue with monkey patching but I haven't found
the cause yet.

Also, you can use,

nLoopingIndex = [1,2,3].length;

for ( ; nLoopingIndex-- ; ) {
    trace(nLoopingIndex);
}

to reverse through a loop when you know the index will always be 0 or
greater.


On Tue, Jul 16, 2013 at 8:16 PM, Mark Kessler
<ke...@gmail.com>wrote:

> Changing the flexsprite wasn't going to get everything.  It was just low
> hanging fruit for a test/example since it allowed me a wide range of
> components to test with.  If I could have changed the EventDispatcher it
> would have been a better :P
>
> I like the looping backwards idea for removing items... will keep me from
> adjusting values as much.  I'll change over to that later.
>
> I started using more getItemAt because not everything allows the brackets
> anymore.  Not sure how much of a speed difference there is.
>
>
> Thanks Justin
>
> -Mark
>
> On Tue, Jul 16, 2013 at 8:41 PM, Justin Mclean <justin@classsoftware.com
> >wrote:
>
> > Hi,
> >
> > >
> >
> https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16
> >
> > Very quick glance, but I think that removing items from a list when
> you're
> > looping to the number of original items in the list can get you into
> > trouble.
> >  for (nLoopingIndex = 0; nLoopingIndex < nListenerTotal; nLoopingIndex++)
> >
> > It's best to loop backwards to avoid this issue. Like so:
> >  for (nLoopingIndex = nListenerTotal -1 ; nLoopingIndex >= 0;
> > nLoopingIndex--)
> >
> > I'd also use bracket notation rather than getItemAt but perhaps that's
> > just me?
> >
> > You might also need to think about stage events and the like.
> >
> > Thanks,
> > Justin
>

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Mark Kessler <ke...@gmail.com>.
Changing the flexsprite wasn't going to get everything.  It was just low
hanging fruit for a test/example since it allowed me a wide range of
components to test with.  If I could have changed the EventDispatcher it
would have been a better :P

I like the looping backwards idea for removing items... will keep me from
adjusting values as much.  I'll change over to that later.

I started using more getItemAt because not everything allows the brackets
anymore.  Not sure how much of a speed difference there is.


Thanks Justin

-Mark

On Tue, Jul 16, 2013 at 8:41 PM, Justin Mclean <ju...@classsoftware.com>wrote:

> Hi,
>
> >
> https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16
>
> Very quick glance, but I think that removing items from a list when you're
> looping to the number of original items in the list can get you into
> trouble.
>  for (nLoopingIndex = 0; nLoopingIndex < nListenerTotal; nLoopingIndex++)
>
> It's best to loop backwards to avoid this issue. Like so:
>  for (nLoopingIndex = nListenerTotal -1 ; nLoopingIndex >= 0;
> nLoopingIndex--)
>
> I'd also use bracket notation rather than getItemAt but perhaps that's
> just me?
>
> You might also need to think about stage events and the like.
>
> Thanks,
> Justin

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Mark Kessler <ke...@gmail.com>.
Changed the looping for the removal methods to go last to first [1].   I've
been playing with a second copy of the code where I override all the
methods and don't bother calling the parent(super).  Been working fine
lol.  Even made an additional addEventLister / event method that removes
itself after the first dispatch.  I think I may keep fiddling with this.
It's providing some good functionality.

[1]
https://github.com/KesslerConsulting/example/commit/5ac765999f7c8a7893dd59b50f43f6650bd60843

-Mark


On Tue, Jul 16, 2013 at 8:41 PM, Justin Mclean <ju...@classsoftware.com>wrote:

> Hi,
>
> >
> https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16
>
> Very quick glance, but I think that removing items from a list when you're
> looping to the number of original items in the list can get you into
> trouble.
>  for (nLoopingIndex = 0; nLoopingIndex < nListenerTotal; nLoopingIndex++)
>
> It's best to loop backwards to avoid this issue. Like so:
>  for (nLoopingIndex = nListenerTotal -1 ; nLoopingIndex >= 0;
> nLoopingIndex--)
>
> I'd also use bracket notation rather than getItemAt but perhaps that's
> just me?
>
> You might also need to think about stage events and the like.
>
> Thanks,
> Justin

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16

Very quick glance, but I think that removing items from a list when you're looping to the number of original items in the list can get you into trouble.
 for (nLoopingIndex = 0; nLoopingIndex < nListenerTotal; nLoopingIndex++)

It's best to loop backwards to avoid this issue. Like so:
 for (nLoopingIndex = nListenerTotal -1 ; nLoopingIndex >= 0; nLoopingIndex--)

I'd also use bracket notation rather than getItemAt but perhaps that's just me?

You might also need to think about stage events and the like.

Thanks,
Justin

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Mark Kessler <ke...@gmail.com>.
Now with links... lol

[1] http://people.apache.org/~mkessler/examples/FLEX-33608/app.swf
[2]
https://github.com/KesslerConsulting/example/commit/30ee4b96911d301ea09516324241c4bc9d734f16



On Tue, Jul 16, 2013 at 8:16 PM, Mark Kessler
<ke...@gmail.com>wrote:

> Well I had some old code laying around that did exactly this.  I've
> stripped it out and created an example with it [1].  It overrides the
> EventDispatcher methods.  I do not plan on checking it into the sdk,
> because it has to be duplicating the EventDispatcher's internal arrays.  It
> would be better to just put a ticket into Adobe to have some methods /
> array's exposed (if they allow it).
>
> But I do plan on ripping the changes out and attaching them to the issue
> as a work around before resolving it.  Does anyone have any change/addition
> ideas before I do?
>
> I did have a simple serving eventlistener I removed, but it works pretty
> good too.
>
>
> -Mark
>
>
> On Thu, Jul 11, 2013 at 5:41 AM, Mark Kessler (JIRA) <ji...@apache.org>wrote:
>
>>
>>      [
>> https://issues.apache.org/jira/browse/FLEX-33608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>>
>> Mark Kessler reassigned FLEX-33608:
>> -----------------------------------
>>
>>     Assignee: Mark Kessler
>>
>> > Add function "removeAllEventListener()"
>> > ---------------------------------------
>> >
>> >                 Key: FLEX-33608
>> >                 URL: https://issues.apache.org/jira/browse/FLEX-33608
>> >             Project: Apache Flex
>> >          Issue Type: New Feature
>> >          Components: Spark Components
>> >    Affects Versions: Apache Flex 4.9.0
>> >            Reporter: Robbyn Gerhardt
>> >            Assignee: Mark Kessler
>> >              Labels: event, removeEventListener
>> >             Fix For: Apache Flex 4.10.0
>> >
>> >   Original Estimate: 12h
>> >  Remaining Estimate: 12h
>> >
>> > Can you add a function that removes all events of a component?
>>
>> --
>> This message is automatically generated by JIRA.
>> If you think it was sent incorrectly, please contact your JIRA
>> administrators
>> For more information on JIRA, see: http://www.atlassian.com/software/jira
>>
>
>

Re: [jira] [Assigned] (FLEX-33608) Add function "removeAllEventListener()"

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> It would be better to just put a ticket into Adobe to have some methods /
> array's exposed (if they allow it).
It's been asked before (many times) but they decided for whatever reasons not to implement it. Was one of the most requested features in Adobe's old bug base.

Does you code detect and remove listeners added to the stage and the like?

Justin