<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flash Player Bug: Removing an event listener in another listener for the same type fails</title>
	<atom:link href="http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/</link>
	<description>Josh Tynjala explores Flash, Flex, and ActionScript.</description>
	<lastBuildDate>Sat, 31 Jul 2010 02:55:11 -0400</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: ian pretorius</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-61873</link>
		<dc:creator>ian pretorius</dc:creator>
		<pubDate>Thu, 19 Nov 2009 12:47:05 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-61873</guid>
		<description>Hi David

&quot;in OOP, both objects hear the event at the same time â€“&quot;

I personally dont believe this statement is true, Actionscript is a single threaded stack based language , thus everything is sequenced according to the stack. Its simply as others have commented, a matter of the API (event.stopPropagation()  , event.stopImmediatePropagation() ) been the entry points into event stack manipulation. I side with Josh in that its a matter of how flash is built and im sure it could be possible to engineer flash to update the copied list via interpreting some flag set by the removeEvent operation with each iteration of proccessing the listeners list.</description>
		<content:encoded><![CDATA[<p>Hi David</p>
<p>&#8220;in OOP, both objects hear the event at the same time â€“&#8221;</p>
<p>I personally dont believe this statement is true, Actionscript is a single threaded stack based language , thus everything is sequenced according to the stack. Its simply as others have commented, a matter of the API (event.stopPropagation()  , event.stopImmediatePropagation() ) been the entry points into event stack manipulation. I side with Josh in that its a matter of how flash is built and im sure it could be possible to engineer flash to update the copied list via interpreting some flag set by the removeEvent operation with each iteration of proccessing the listeners list.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-61490</link>
		<dc:creator>David</dc:creator>
		<pubDate>Mon, 07 Sep 2009 21:26:05 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-61490</guid>
		<description>Hey Josh,

The reason the event is still caught by dispatcherComplete2Handler is because this is Object Orientated Programming.

If you have mainly done procedural programming, you would expect the first handler to remove the second handler&#039;s listener... in OOP, both objects hear the event at the same time - so by the time you have removed the listener, it is too late.

Hope this helps out.
Dave.</description>
		<content:encoded><![CDATA[<p>Hey Josh,</p>
<p>The reason the event is still caught by dispatcherComplete2Handler is because this is Object Orientated Programming.</p>
<p>If you have mainly done procedural programming, you would expect the first handler to remove the second handler&#8217;s listener&#8230; in OOP, both objects hear the event at the same time &#8211; so by the time you have removed the listener, it is too late.</p>
<p>Hope this helps out.<br />
Dave.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adampasz</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60866</link>
		<dc:creator>adampasz</dc:creator>
		<pubDate>Sun, 05 Apr 2009 19:27:51 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60866</guid>
		<description>Never mind my second question.  I see that the event is dispatched from the *copy* of the list, but removeEventListener operates on the original list.</description>
		<content:encoded><![CDATA[<p>Never mind my second question.  I see that the event is dispatched from the *copy* of the list, but removeEventListener operates on the original list.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adampasz</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60865</link>
		<dc:creator>adampasz</dc:creator>
		<pubDate>Sun, 05 Apr 2009 19:24:04 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60865</guid>
		<description>&quot;When an event is being dispatched, the event dispatcher makes a copy of the event listeners list. So this list canâ€™t be changed during the dispatch of an event.&quot;
As a developer, how would I possibly know this (without reading your post).  If the event list is locked during event dispatching, I would at least expect some kind of exception to be thrown to let me know that I&#039;m doing something wrong by trying to modify the list.  Also, if the list can&#039;t be changed during dispatch, wouldn&#039;t the output be:
1
2
1
2</description>
		<content:encoded><![CDATA[<p>&#8220;When an event is being dispatched, the event dispatcher makes a copy of the event listeners list. So this list canâ€™t be changed during the dispatch of an event.&#8221;<br />
As a developer, how would I possibly know this (without reading your post).  If the event list is locked during event dispatching, I would at least expect some kind of exception to be thrown to let me know that I&#8217;m doing something wrong by trying to modify the list.  Also, if the list can&#8217;t be changed during dispatch, wouldn&#8217;t the output be:<br />
1<br />
2<br />
1<br />
2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60854</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Thu, 02 Apr 2009 14:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60854</guid>
		<description>Elliot, calling &lt;code&gt;stopImmediatePropogation()&lt;/code&gt; on a GTween event won&#039;t help at all. That will stop one GTween instance from updating further listeners, but it will have no effect on other GTween instances. If &lt;em&gt;A&lt;/em&gt; is paused during &lt;em&gt;B&lt;/em&gt;&#039;s event, &lt;em&gt;A&lt;/em&gt; will still receive the &lt;code&gt;&quot;tick&quot;&lt;/code&gt; event from the internal timing mechanism and update one last time. Stopping propagation on a GTween instance&#039;s events does not stop propagation of events from this timer, and it definitely shouldn&#039;t because that could affect instances that have not been paused.</description>
		<content:encoded><![CDATA[<p>Elliot, calling <code>stopImmediatePropogation()</code> on a GTween event won&#8217;t help at all. That will stop one GTween instance from updating further listeners, but it will have no effect on other GTween instances. If <em>A</em> is paused during <em>B</em>&#8216;s event, <em>A</em> will still receive the <code>"tick"</code> event from the internal timing mechanism and update one last time. Stopping propagation on a GTween instance&#8217;s events does not stop propagation of events from this timer, and it definitely shouldn&#8217;t because that could affect instances that have not been paused.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliot Chong</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60853</link>
		<dc:creator>Elliot Chong</dc:creator>
		<pubDate>Thu, 02 Apr 2009 13:52:15 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60853</guid>
		<description>&quot;pausing a GTween inside an event listener attached to another GTween causes the supposedly-paused GTween to update the target&#039;s properties one last time&quot;

If you place a stopImmediatePropagation() immediately after your pause statement for a tween, then priority should be more or less irrelevant in that instance.  The final value will still be the the one set right when you paused it, as nothing will be updated after that.

I&#039;m unsure of when GTween would need any different behavior, as developers are tasked with assigning the listeners for the tween&#039;s updates, completes, etc.  Could you give an example for when a developer using GTween wouldn&#039;t be able to use this method effectively?</description>
		<content:encoded><![CDATA[<p>&#8220;pausing a GTween inside an event listener attached to another GTween causes the supposedly-paused GTween to update the target&#8217;s properties one last time&#8221;</p>
<p>If you place a stopImmediatePropagation() immediately after your pause statement for a tween, then priority should be more or less irrelevant in that instance.  The final value will still be the the one set right when you paused it, as nothing will be updated after that.</p>
<p>I&#8217;m unsure of when GTween would need any different behavior, as developers are tasked with assigning the listeners for the tween&#8217;s updates, completes, etc.  Could you give an example for when a developer using GTween wouldn&#8217;t be able to use this method effectively?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60851</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Wed, 01 Apr 2009 17:21:41 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60851</guid>
		<description>Thanks for the comments, folks. Personally, I&#039;m still not convinced. For the record, I have no problem with event propagation and priorities. I use these features often. What&#039;s interesting is that you all make this suggestion to use them, but Grant probably &lt;em&gt;won&#039;t&lt;/em&gt; be able to do that in GTween. He has an arbitrary number of event listeners where the only way to calculate a useful priority is after removing one of the listeners (and unless I&#039;m wrong, you can&#039;t change priorities at that point!). My GTween workaround above will probably be enough, but it certainly feels like more like a hack than a fix.</description>
		<content:encoded><![CDATA[<p>Thanks for the comments, folks. Personally, I&#8217;m still not convinced. For the record, I have no problem with event propagation and priorities. I use these features often. What&#8217;s interesting is that you all make this suggestion to use them, but Grant probably <em>won&#8217;t</em> be able to do that in GTween. He has an arbitrary number of event listeners where the only way to calculate a useful priority is after removing one of the listeners (and unless I&#8217;m wrong, you can&#8217;t change priorities at that point!). My GTween workaround above will probably be enough, but it certainly feels like more like a hack than a fix.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliot Chong</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60849</link>
		<dc:creator>Elliot Chong</dc:creator>
		<pubDate>Wed, 01 Apr 2009 15:39:44 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60849</guid>
		<description>I also believe this is working as intended... I understand the confusion, but it&#039;s not really a Flash Player bug.

I&#039;d recommend setting the priority of the event listener you want to capture first higher than the others, and then use event.stopImmediatePropagation() in your listener to stop it from reaching subsequent listeners in the event chain.</description>
		<content:encoded><![CDATA[<p>I also believe this is working as intended&#8230; I understand the confusion, but it&#8217;s not really a Flash Player bug.</p>
<p>I&#8217;d recommend setting the priority of the event listener you want to capture first higher than the others, and then use event.stopImmediatePropagation() in your listener to stop it from reaching subsequent listeners in the event chain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Mariani</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60848</link>
		<dc:creator>Gabriel Mariani</dc:creator>
		<pubDate>Wed, 01 Apr 2009 11:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60848</guid>
		<description>But that&#039;s the thing. You&#039;re NOT removing it before the other event listener is being called. Like Joeri said, it&#039;s a propagation stream, and in order to interrupt it (like what you are trying to do) is why they have stopPropagation() in the first place. They already solved for your problem, you just don&#039;t like the solution.</description>
		<content:encoded><![CDATA[<p>But that&#8217;s the thing. You&#8217;re NOT removing it before the other event listener is being called. Like Joeri said, it&#8217;s a propagation stream, and in order to interrupt it (like what you are trying to do) is why they have stopPropagation() in the first place. They already solved for your problem, you just don&#8217;t like the solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2009/03/31/flash-player-bug-removing-an-event-listener-in-another-listener-for-the-same-type-fails/comment-page-1/#comment-60847</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Wed, 01 Apr 2009 09:06:12 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=555#comment-60847</guid>
		<description>Joeri, I considered that possibility, and I assume that&#039;s probably how Flash Player is implemented. Even considering that, I still argue that it&#039;s behaving incorrectly. If I remove an event listener before it is called, then I should not receive that event. I don&#039;t care if I do it in another event listener or anywhere else. This implementation opens up a can of worms that only the most experienced developers will be able to easily understand. Honestly, who considers the possibility that an event might still be received after you&#039;ve explicitly called &lt;code&gt;removeEventListener()&lt;/code&gt;? Only the most superstitious coders, in my opinion.</description>
		<content:encoded><![CDATA[<p>Joeri, I considered that possibility, and I assume that&#8217;s probably how Flash Player is implemented. Even considering that, I still argue that it&#8217;s behaving incorrectly. If I remove an event listener before it is called, then I should not receive that event. I don&#8217;t care if I do it in another event listener or anywhere else. This implementation opens up a can of worms that only the most experienced developers will be able to easily understand. Honestly, who considers the possibility that an event might still be received after you&#8217;ve explicitly called <code>removeEventListener()</code>? Only the most superstitious coders, in my opinion.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
