<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Event Handlers versus Event Listeners</title>
	<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Thu, 09 Sep 2010 11:09:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Jorge</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-430188</link>
		<pubDate>Mon, 14 Dec 2009 01:41:22 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-430188</guid>
					<description>Hi David!

First let me tell you that I have found in your website great stuff that has helped me on my projects. I'm starting on Flash and here with your articles I a have found great source of information that really has added value to my work! Thank you!

Now to my question ;D

Let me tell what my intention is:
I have a DB in MySQL that has events. On my clip myEvents.swf
I create a movieclip object that has each record, at the end of the line I included a button. So the table is displayed and each record has a button. My goal is when the user clicks on this button the ID of the record will be passed to the main movieclip and go to the edit frame so the user can edit the info. Am I in the right direction with this events listeners or there is a better way to pass the info to the parent movie without getting into this?In my main movie I added the listener object, the function of what to do and I added to the instance of the edit button the event. But when testing it, nothing happens! I'm missing something, please help!

Thanks in advance. 

In my frame this is the code:
(I hope is not confusing - the info I display on this area are events, that's why the name of the swf and also the name of the button).

//Load Movieclip to target area
loadMovie(&quot;myevents.swf?ver=&quot; + Math.floor(Math.random() * 999),&quot;area_6.targetbox&quot;);

 // Create listener object for the Events Edit Button.
var ebListener:Object = new Object(); 
ebListener.onRelease = function(evt_obj:Object){
  do Something... 
};

// Add the Function_Event to the Button that is the listener.
edit_event.addEventListener(&quot;onRelease&quot;, ebListener);</description>
		<content:encoded><![CDATA[<p>Hi David!</p>
<p>First let me tell you that I have found in your website great stuff that has helped me on my projects. I&#8217;m starting on Flash and here with your articles I a have found great source of information that really has added value to my work! Thank you!</p>
<p>Now to my question ;D</p>
<p>Let me tell what my intention is:<br />
I have a DB in MySQL that has events. On my clip myEvents.swf<br />
I create a movieclip object that has each record, at the end of the line I included a button. So the table is displayed and each record has a button. My goal is when the user clicks on this button the ID of the record will be passed to the main movieclip and go to the edit frame so the user can edit the info. Am I in the right direction with this events listeners or there is a better way to pass the info to the parent movie without getting into this?In my main movie I added the listener object, the function of what to do and I added to the instance of the edit button the event. But when testing it, nothing happens! I&#8217;m missing something, please help!</p>
<p>Thanks in advance. </p>
<p>In my frame this is the code:<br />
(I hope is not confusing - the info I display on this area are events, that&#8217;s why the name of the swf and also the name of the button).</p>
<p>//Load Movieclip to target area<br />
loadMovie(&#8221;myevents.swf?ver=&#8221; + Math.floor(Math.random() * 999),&#8221;area_6.targetbox&#8221;);</p>
<p> // Create listener object for the Events Edit Button.<br />
var ebListener:Object = new Object();<br />
ebListener.onRelease = function(evt_obj:Object){<br />
  do Something&#8230;<br />
};</p>
<p>// Add the Function_Event to the Button that is the listener.<br />
edit_event.addEventListener(&#8221;onRelease&#8221;, ebListener);
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Elinkintese</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-323196</link>
		<pubDate>Fri, 19 Dec 2008 00:25:40 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-323196</guid>
					<description>Hello 
 
As a fresh www.quip.net user i just wanted to say hello to everyone else who uses this bbs :D</description>
		<content:encoded><![CDATA[<p>Hello </p>
<p>As a fresh <a href='http://www.quip.net' rel='nofollow'>www.quip.net</a> user i just wanted to say hello to everyone else who uses this bbs <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-247024</link>
		<pubDate>Tue, 12 Aug 2008 03:13:20 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-247024</guid>
					<description>automator,

&lt;blockquote&gt;When you say “an event is raised by an object”, is it the same as saying “an object broadcasts an event”.&lt;/blockquote&gt;

I would say yes.  In day-to-day discussions, I generally hear the concept in question described as &quot;an event being raised,&quot; &quot;an event being triggered,&quot; and &quot;an event being broadcast.&quot;  All of these refer to an event &lt;em&gt;occurring&lt;/em&gt;, and then it's up to your event handler function to &quot;handle&quot; the event.

The part where it gets hazy &amp;#8212; and this may be 100% in the way I (mis)represented the concept &amp;#8212; is that even listeners can be said to handle events.  That makes the phrase &quot;event handlers vs. event listeners&quot; potentially confusing.

What I'm calling &quot;event handlers&quot; in this article are essentially nothing more than properties, if you look carefully at it (and maybe I should have been more careful! ;)).  The &lt;code&gt;Button.onRelease&lt;/code&gt; &quot;property&quot; is assigned to a function, which makes it actually &lt;em&gt;do&lt;/em&gt; something when its namesake event occurs.

What I'm calling &quot;event handlers&quot; have a one-to-one correspondence between the event and the triggered function.  What I'm calling &quot;event listeners&quot; can have a one-to-many correspondence.  You might, for example, have 100 different listeners all listening for a particular event to be broadcast.  It's in that scenario that the term &quot;broadcast&quot; seems (to me) like a good fit.  But out of laziness, perhaps, I often use the word &quot;broadcast&quot; for all of the above.

I hope that clears the somewhat muddy water!</description>
		<content:encoded><![CDATA[<p>automator,</p>
<blockquote><p>When you say “an event is raised by an object”, is it the same as saying “an object broadcasts an event”.</p></blockquote>
<p>I would say yes.  In day-to-day discussions, I generally hear the concept in question described as &#8220;an event being raised,&#8221; &#8220;an event being triggered,&#8221; and &#8220;an event being broadcast.&#8221;  All of these refer to an event <em>occurring</em>, and then it&#8217;s up to your event handler function to &#8220;handle&#8221; the event.</p>
<p>The part where it gets hazy &mdash; and this may be 100% in the way I (mis)represented the concept &mdash; is that even listeners can be said to handle events.  That makes the phrase &#8220;event handlers vs. event listeners&#8221; potentially confusing.</p>
<p>What I&#8217;m calling &#8220;event handlers&#8221; in this article are essentially nothing more than properties, if you look carefully at it (and maybe I should have been more careful! <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).  The <code>Button.onRelease</code> &#8220;property&#8221; is assigned to a function, which makes it actually <em>do</em> something when its namesake event occurs.</p>
<p>What I&#8217;m calling &#8220;event handlers&#8221; have a one-to-one correspondence between the event and the triggered function.  What I&#8217;m calling &#8220;event listeners&#8221; can have a one-to-many correspondence.  You might, for example, have 100 different listeners all listening for a particular event to be broadcast.  It&#8217;s in that scenario that the term &#8220;broadcast&#8221; seems (to me) like a good fit.  But out of laziness, perhaps, I often use the word &#8220;broadcast&#8221; for all of the above.</p>
<p>I hope that clears the somewhat muddy water!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: automator</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-235871</link>
		<pubDate>Fri, 01 Aug 2008 13:06:02 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-235871</guid>
					<description>Hi, David! Thanks for this informative article. I'm currently in the process of understanding the difference between event handlers and event listeners and your article has helped a lot (although I'm still a bit confused, but considerably less confused than I was before reading your explanation :) ). Would you be so kind as to clarify something for me? When you say &quot;an event is raised by an object&quot;, is it the same as saying &quot;an object broadcasts an event&quot;. For example, when you press a button (let's say it has the name myBtn), the myBtn button instance &quot;raises the onPress event&quot;, and if an onPress event handler method is assigned to myBtn, then the onPress event handler method is invoked and then something happens (plays a sound, for example). Would this explanation be somewhat correct as well:

When myBtn is pressed, it &quot;broadcasts&quot;: &quot;hey, I've just been pressed!&quot;. And then the event handler method (which is assigned to the myBtn button) is activated and then something happens.

Would that be a correct explanation? Because the way I understand it is that with event handlers, the object that &quot;broadcasts&quot; the event is also the one listening out for when that specific event is broadcast (so the object is kinda like talking to itself). Where as with event listeners, one object broadcasts the event and then another different object (the listener object) listens out for those events that are broadcast.</description>
		<content:encoded><![CDATA[<p>Hi, David! Thanks for this informative article. I&#8217;m currently in the process of understanding the difference between event handlers and event listeners and your article has helped a lot (although I&#8217;m still a bit confused, but considerably less confused than I was before reading your explanation <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). Would you be so kind as to clarify something for me? When you say &#8220;an event is raised by an object&#8221;, is it the same as saying &#8220;an object broadcasts an event&#8221;. For example, when you press a button (let&#8217;s say it has the name myBtn), the myBtn button instance &#8220;raises the onPress event&#8221;, and if an onPress event handler method is assigned to myBtn, then the onPress event handler method is invoked and then something happens (plays a sound, for example). Would this explanation be somewhat correct as well:</p>
<p>When myBtn is pressed, it &#8220;broadcasts&#8221;: &#8220;hey, I&#8217;ve just been pressed!&#8221;. And then the event handler method (which is assigned to the myBtn button) is activated and then something happens.</p>
<p>Would that be a correct explanation? Because the way I understand it is that with event handlers, the object that &#8220;broadcasts&#8221; the event is also the one listening out for when that specific event is broadcast (so the object is kinda like talking to itself). Where as with event listeners, one object broadcasts the event and then another different object (the listener object) listens out for those events that are broadcast.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-179143</link>
		<pubDate>Thu, 08 May 2008 03:55:24 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-179143</guid>
					<description>Swan,

Thanks!  I really do &lt;em&gt;try&lt;/em&gt; to always respond.  Sometimes it takes me a very long time.</description>
		<content:encoded><![CDATA[<p>Swan,</p>
<p>Thanks!  I really do <em>try</em> to always respond.  Sometimes it takes me a very long time.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Swan</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-171707</link>
		<pubDate>Tue, 29 Apr 2008 05:22:08 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-171707</guid>
					<description>Thanks,
Btw, the good thing i like about quip, is that you ALWAYS respond, with a reply. :)</description>
		<content:encoded><![CDATA[<p>Thanks,<br />
Btw, the good thing i like about quip, is that you ALWAYS respond, with a reply. <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-171458</link>
		<pubDate>Mon, 28 Apr 2008 12:55:43 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-171458</guid>
					<description>Swan,

I can't answer authoritatively why &lt;code&gt;addEventListener()&lt;/code&gt; needs the seemingly redundant information, but for what it's worth, that method is the preferred approach in ActionScript 3.0.  With very few exceptions, &lt;code&gt;addEventListener()&lt;/code&gt; is &lt;em&gt;the&lt;/em&gt; new way to handle events.  The other approaches, including &lt;code&gt;addListener()&lt;/code&gt; are a result of new functionality added to Flash over the years.  So the reason there are two &quot;binders,&quot; at least in ActionScript 2.0, may well be that various teams worked on various implementations of the API over various years.</description>
		<content:encoded><![CDATA[<p>Swan,</p>
<p>I can&#8217;t answer authoritatively why <code>addEventListener()</code> needs the seemingly redundant information, but for what it&#8217;s worth, that method is the preferred approach in ActionScript 3.0.  With very few exceptions, <code>addEventListener()</code> is <em>the</em> new way to handle events.  The other approaches, including <code>addListener()</code> are a result of new functionality added to Flash over the years.  So the reason there are two &#8220;binders,&#8221; at least in ActionScript 2.0, may well be that various teams worked on various implementations of the API over various years.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Swan</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-171439</link>
		<pubDate>Mon, 28 Apr 2008 11:40:02 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-171439</guid>
					<description>One thing, that, i was searching explanation for is :
Why there are two types of &quot;binders&quot; ie.

1) AddEventListener 
2) AddListener.

The 2nd one can be understood, but the 1st one always confuses, as why there is the necessity of mentioning the type of event which is going to be bound with the object. As in the following case :

mylistener.click = function () { // do something }
mybutton.addEventListener ( &quot;click&quot;, mylistener )</description>
		<content:encoded><![CDATA[<p>One thing, that, i was searching explanation for is :<br />
Why there are two types of &#8220;binders&#8221; ie.</p>
<p>1) AddEventListener<br />
2) AddListener.</p>
<p>The 2nd one can be understood, but the 1st one always confuses, as why there is the necessity of mentioning the type of event which is going to be bound with the object. As in the following case :</p>
<p>mylistener.click = function () { // do something }<br />
mybutton.addEventListener ( &#8220;click&#8221;, mylistener )
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-22551</link>
		<pubDate>Fri, 09 Mar 2007 15:26:47 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-22551</guid>
					<description>Travis,

Flex operates in ActionScript 3.0 land, which requires a whole new map.  The principles are the same &amp;#8212; you would still need to convert those raw images into whatever class instance meets your needs &amp;#8212; but you'd have to change gears quite a bit.  Flex Builder 2 has no timeline or drawing tools.  It's a different IDE that caters to a different sort of developer.

That said, Flex Builder 2 is arguably &quot;just another&quot; ActionScript editor, same as Flash.  I put that in quotes because both applications are immensely complex, and Flex Builder 2 is an &lt;em&gt;awesome&lt;/em&gt; code editor &amp;#8212; but the point is that &lt;em&gt;ActionScript&lt;/em&gt; is what matters.  The tool used to write it isn't nearly as important as what the language requires or is capable of.  (Honestly, you can produce SWFs without any Adobe software at all [see osflash.org].)  So even in Flex, you'll have to mass-convert those images.

The Flash IDE is programmable via JSFL, and that might be a good solution for you.  See the &quot;Extending Flash&quot; book in the documentation.  If you're comfortable with JavaScript, you'll find you can program the IDE by way of a DOM what works, in principle, to the DOM in HTML.</description>
		<content:encoded><![CDATA[<p>Travis,</p>
<p>Flex operates in ActionScript 3.0 land, which requires a whole new map.  The principles are the same &mdash; you would still need to convert those raw images into whatever class instance meets your needs &mdash; but you&#8217;d have to change gears quite a bit.  Flex Builder 2 has no timeline or drawing tools.  It&#8217;s a different IDE that caters to a different sort of developer.</p>
<p>That said, Flex Builder 2 is arguably &#8220;just another&#8221; ActionScript editor, same as Flash.  I put that in quotes because both applications are immensely complex, and Flex Builder 2 is an <em>awesome</em> code editor &mdash; but the point is that <em>ActionScript</em> is what matters.  The tool used to write it isn&#8217;t nearly as important as what the language requires or is capable of.  (Honestly, you can produce SWFs without any Adobe software at all [see osflash.org].)  So even in Flex, you&#8217;ll have to mass-convert those images.</p>
<p>The Flash IDE is programmable via JSFL, and that might be a good solution for you.  See the &#8220;Extending Flash&#8221; book in the documentation.  If you&#8217;re comfortable with JavaScript, you&#8217;ll find you can program the IDE by way of a DOM what works, in principle, to the DOM in HTML.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Travis</title>
		<link>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-22549</link>
		<pubDate>Fri, 09 Mar 2007 15:04:37 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/event-handlers-listeners#comment-22549</guid>
					<description>Wow, thanks for the quick reply.


I was afraid that is what the answer would be.

So I guess the question is should I do this programmatically or manually? I had gotten atleast a portion of this work by converting a couple of the pairs to movieclips. However, to do this I had to &quot;break apart&quot; all of the grouping within flash which caused my zoom to stop working. 

In a language I am actually familliar with, I would create my own nested movieclip sublass that holds an instance of the icon( shape ) and the text portion each as its own movieclip, so that I can control the changes individually and still tie the event handling to the overall symbol. However, manually creating these symbols doesnt seem to work this way. 

I do not expect  you to give me all the answers here, I am just not really sure what to start looking for in the documentation or tutorials.

Would I be better off trying to do this in Flex?

Thanks again for your help.</description>
		<content:encoded><![CDATA[<p>Wow, thanks for the quick reply.</p>
<p>I was afraid that is what the answer would be.</p>
<p>So I guess the question is should I do this programmatically or manually? I had gotten atleast a portion of this work by converting a couple of the pairs to movieclips. However, to do this I had to &#8220;break apart&#8221; all of the grouping within flash which caused my zoom to stop working. </p>
<p>In a language I am actually familliar with, I would create my own nested movieclip sublass that holds an instance of the icon( shape ) and the text portion each as its own movieclip, so that I can control the changes individually and still tie the event handling to the overall symbol. However, manually creating these symbols doesnt seem to work this way. </p>
<p>I do not expect  you to give me all the answers here, I am just not really sure what to start looking for in the documentation or tutorials.</p>
<p>Would I be better off trying to do this in Flex?</p>
<p>Thanks again for your help.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
