<?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: Learned Something About Events in ActionScript 3</title>
	<atom:link href="http://www.curiousfind.com/blog/164/feed" rel="self" type="application/rss+xml" />
	<link>http://www.curiousfind.com/blog/164</link>
	<description>Web development by Jamie McDaniel</description>
	<lastBuildDate>Wed, 14 Jul 2010 07:29:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jamie McDaniel</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-7172</link>
		<dc:creator>Jamie McDaniel</dc:creator>
		<pubDate>Thu, 17 Sep 2009 16:10:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-7172</guid>
		<description>Update: I retook the test today and noted the exact wording of the question.  It was &quot;Which nature of ActionScript is depicted by the use of Events:  Synchronous, Asynchronous, Procedure oriented, or Object oriented?&quot;</description>
		<content:encoded><![CDATA[<p>Update: I retook the test today and noted the exact wording of the question.  It was &#8220;Which nature of ActionScript is depicted by the use of Events:  Synchronous, Asynchronous, Procedure oriented, or Object oriented?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie McDaniel</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-7106</link>
		<dc:creator>Jamie McDaniel</dc:creator>
		<pubDate>Mon, 14 Sep 2009 22:50:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-7106</guid>
		<description>More insight from &lt;em&gt;Professional Adobe Flex 3&lt;/em&gt;, page 20: &quot;The Flash Player follows a single-threaded execution model, with the exception of specific advances related to Flash Player 10. This means that event handling is synchronous, which may take some getting used to for users of multithreaded languages. A single-threaded model has the advantage of simplified event propagation and debugging, and since there are no race conditions or deadlocks to worry about, it simplifies the coding of certain class structures such as the Singleton design pattern.&quot;</description>
		<content:encoded><![CDATA[<p>More insight from <em>Professional Adobe Flex 3</em>, page 20: &#8220;The Flash Player follows a single-threaded execution model, with the exception of specific advances related to Flash Player 10. This means that event handling is synchronous, which may take some getting used to for users of multithreaded languages. A single-threaded model has the advantage of simplified event propagation and debugging, and since there are no race conditions or deadlocks to worry about, it simplifies the coding of certain class structures such as the Singleton design pattern.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie McDaniel</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-6057</link>
		<dc:creator>Jamie McDaniel</dc:creator>
		<pubDate>Sun, 12 Jul 2009 23:33:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-6057</guid>
		<description>@greg, Apologies... your comment got held up for moderation due to the number of links, so I did not see it until just now.  (I&#039;ve since upped the number.)  Thank you for the helpful explanation.  I understand the examples you and Alan gave about Event.COMPLETE and ResultEvent.RESULT being dispatched at a future point in time after calls to Loader.load(), HTTPService.send(), etc.  I think I was uncertain about what happens once the event is actually dispatched.  And it seems EventDispatcher immediately looks up the handlers and executes them (i.e. synchronous code execution) before proceeding to the line of code following dispatchEvent().

But I am now certain that you all are correct in that the answer the test was looking for was 2. Asynchronous execution. The question was referencing the fact that calling certain methods does not provide immediate results, but rather the result (or error) is returned via an event that is dispatched at some future, arbitrary time -- hence asynchronous execution.  Did I get it?  :-)</description>
		<content:encoded><![CDATA[<p>@greg, Apologies&#8230; your comment got held up for moderation due to the number of links, so I did not see it until just now.  (I&#8217;ve since upped the number.)  Thank you for the helpful explanation.  I understand the examples you and Alan gave about Event.COMPLETE and ResultEvent.RESULT being dispatched at a future point in time after calls to Loader.load(), HTTPService.send(), etc.  I think I was uncertain about what happens once the event is actually dispatched.  And it seems EventDispatcher immediately looks up the handlers and executes them (i.e. synchronous code execution) before proceeding to the line of code following dispatchEvent().</p>
<p>But I am now certain that you all are correct in that the answer the test was looking for was 2. Asynchronous execution. The question was referencing the fact that calling certain methods does not provide immediate results, but rather the result (or error) is returned via an event that is dispatched at some future, arbitrary time &#8212; hence asynchronous execution.  Did I get it?  <img src='http://www.curiousfind.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie McDaniel</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-6056</link>
		<dc:creator>Jamie McDaniel</dc:creator>
		<pubDate>Sun, 12 Jul 2009 23:14:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-6056</guid>
		<description>Thanks for providing insight Kim &amp; Alan.  I wish I could remember how the question was phrased exactly, because I am probably missing some important word.  Also, I should say that this was not an official Adobe question, like on a certification test.  It was the ActionScript 3 test over at oDesk.

Alan, what you describe as allowing an app to run asynchronously are server calls.  I&#039;ve seen the word &quot;asynchronous&quot; used many times in the official documentation for HTTPService, WebService, and RemoteObject in Flex.  For example, when you call the send() method on HTTPService, the Flash player calls the service and then continues to execute code, not waiting around for the result.  The HTTPService&#039;s ResultEvent is dispatched only when the server call returns successfully at some future time.   (For anyone following this discussion, here is a &lt;a href=&quot;http://forums.adobe.com/thread/443557&quot; rel=&quot;nofollow&quot;&gt;forum post&lt;/a&gt; where Adobe employee Tom Lane explains it better than I can.)

Kim, point taken. &lt;a href=&quot;http://en.wikipedia.org/wiki/Event-driven_programming&quot; rel=&quot;nofollow&quot;&gt;Event-driven programming&lt;/a&gt; versus old-school BASIC and other languages where code execution flowed from line 1 to the end of the program and then it looped back.  However, what I wondered about the question was what I demonstrated -- that dispatchEvent() is a synchronous operation.  Assigning an event handler function to an event and then dispatching that event is exactly the same as calling the event handler function directly (not taking into account such things as the priority argument passed in via addEventListener, or the capture/bubble phases, or event.stopPropagation(), etc.)  Do you agree?</description>
		<content:encoded><![CDATA[<p>Thanks for providing insight Kim &#038; Alan.  I wish I could remember how the question was phrased exactly, because I am probably missing some important word.  Also, I should say that this was not an official Adobe question, like on a certification test.  It was the ActionScript 3 test over at oDesk.</p>
<p>Alan, what you describe as allowing an app to run asynchronously are server calls.  I&#8217;ve seen the word &#8220;asynchronous&#8221; used many times in the official documentation for HTTPService, WebService, and RemoteObject in Flex.  For example, when you call the send() method on HTTPService, the Flash player calls the service and then continues to execute code, not waiting around for the result.  The HTTPService&#8217;s ResultEvent is dispatched only when the server call returns successfully at some future time.   (For anyone following this discussion, here is a <a href="http://forums.adobe.com/thread/443557" rel="nofollow">forum post</a> where Adobe employee Tom Lane explains it better than I can.)</p>
<p>Kim, point taken. <a href="http://en.wikipedia.org/wiki/Event-driven_programming" rel="nofollow">Event-driven programming</a> versus old-school BASIC and other languages where code execution flowed from line 1 to the end of the program and then it looped back.  However, what I wondered about the question was what I demonstrated &#8212; that dispatchEvent() is a synchronous operation.  Assigning an event handler function to an event and then dispatching that event is exactly the same as calling the event handler function directly (not taking into account such things as the priority argument passed in via addEventListener, or the capture/bubble phases, or event.stopPropagation(), etc.)  Do you agree?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-6051</link>
		<dc:creator>Kim</dc:creator>
		<pubDate>Sun, 12 Jul 2009 15:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-6051</guid>
		<description>The answer is #2 because the whole idea of the event system in Flash (as with other langauges) is asynchronous code execution - the premise that code does NOT have to follow a pre-ordained sequencer of execution and is independent of time.</description>
		<content:encoded><![CDATA[<p>The answer is #2 because the whole idea of the event system in Flash (as with other langauges) is asynchronous code execution &#8211; the premise that code does NOT have to follow a pre-ordained sequencer of execution and is independent of time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-6049</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Sun, 12 Jul 2009 14:32:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-6049</guid>
		<description>Thinking about it, I don&#039;t think that multiple choice question is a good question.  I would believe that the best answer is #2.

I chose to say &#039;best&#039; and not &#039;correct&#039;, because I believe that you just demonstrated how an event can be used in a synchronous manner, but the purpose of events is to enable an app to execute asynchronously.

Example: When using an app like Photoshop, when I save an image the app will pause while it writes the file to disk - locking out any user interaction until it is complete. This is synchronous behavior.  In a Java or Flash app, the user may be constantly reading and writing to a remote database.  If Flash was synchronous, then the app would pause until a database read or write was completed.

I see that question as a bad question. As you pointed out, Flash&#039;s event structure may work synchronously, but I believe the intent is for an app to run synchronously.</description>
		<content:encoded><![CDATA[<p>Thinking about it, I don&#8217;t think that multiple choice question is a good question.  I would believe that the best answer is #2.</p>
<p>I chose to say &#8216;best&#8217; and not &#8216;correct&#8217;, because I believe that you just demonstrated how an event can be used in a synchronous manner, but the purpose of events is to enable an app to execute asynchronously.</p>
<p>Example: When using an app like Photoshop, when I save an image the app will pause while it writes the file to disk &#8211; locking out any user interaction until it is complete. This is synchronous behavior.  In a Java or Flash app, the user may be constantly reading and writing to a remote database.  If Flash was synchronous, then the app would pause until a database read or write was completed.</p>
<p>I see that question as a bad question. As you pointed out, Flash&#8217;s event structure may work synchronously, but I believe the intent is for an app to run synchronously.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: greg h</title>
		<link>http://www.curiousfind.com/blog/164/comment-page-1#comment-6042</link>
		<dc:creator>greg h</dc:creator>
		<pubDate>Sun, 12 Jul 2009 07:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=164#comment-6042</guid>
		<description>Hi Jamie,

The correct answer is 2. Asynchronous Execution.

This is a good concept to understand.

The order of the traces in your example did not have to be in that order.  For instance, if you replace your dispatchEvent with a statement to load an external file, the latency of the network call may result in the complete event being after the subsequent statements like your trace(&quot;hello&quot;);

Synchronous means blocking.  When a synchronous operation is being performed, the code pauses and waits for the completion of the synchronous operation before moving on to execute subsequent statements.

Oddly, one of the best explanations is in the AIR docs (because developers can choose to execute AIR database calls either synchronously or asynchronously).  See this page in the docs:
Using synchronous and asynchronous database operations
http://help.adobe.com/en_US/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7d39.html

The &quot;Programming Adobe ActionScript 3.0&quot; doc does include this:
http://livedocs.adobe.com/flash/9.0/main/00000096.html
Asynchronous: A program command such as a method call that doesn’t provide an immediate result; instead it gives a result (or error) in the form of an event.

And the earlier, but still great Colin Moock&#039;s &quot;ActionScript for Flash MX: The Definitive Guide&quot; has the following:

Event-Based Asynchronous Code Execution
http://www.adobe.com/devnet/flash/articles/actionscript.html

Event-Based Asynchronous Code Execution
&quot;Some code does not execute in a predetermined sequence. Instead, it executes when the ActionScript interpreter notices that an event has occurred. Many events involve a user action, such as clicking the mouse, resizing the movie, or pressing a key. Other events happen without user intervention, such as a sound completing or an XML document loading. Just as the playhead entering a new frame executes synchronous code attached to the frame, events can cause event-based code to execute. Event-based code (code that executes in response to an event) is said to be executed asynchronously because the triggering of events can occur at arbitrary times.

hth,

g</description>
		<content:encoded><![CDATA[<p>Hi Jamie,</p>
<p>The correct answer is 2. Asynchronous Execution.</p>
<p>This is a good concept to understand.</p>
<p>The order of the traces in your example did not have to be in that order.  For instance, if you replace your dispatchEvent with a statement to load an external file, the latency of the network call may result in the complete event being after the subsequent statements like your trace(&#8220;hello&#8221;);</p>
<p>Synchronous means blocking.  When a synchronous operation is being performed, the code pauses and waits for the completion of the synchronous operation before moving on to execute subsequent statements.</p>
<p>Oddly, one of the best explanations is in the AIR docs (because developers can choose to execute AIR database calls either synchronously or asynchronously).  See this page in the docs:<br />
Using synchronous and asynchronous database operations<br />
<a href="http://help.adobe.com/en_US/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7d39.html" rel="nofollow">http://help.adobe.com/en_US/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7d39.html</a></p>
<p>The &#8220;Programming Adobe ActionScript 3.0&#8243; doc does include this:<br />
<a href="http://livedocs.adobe.com/flash/9.0/main/00000096.html" rel="nofollow">http://livedocs.adobe.com/flash/9.0/main/00000096.html</a><br />
Asynchronous: A program command such as a method call that doesn’t provide an immediate result; instead it gives a result (or error) in the form of an event.</p>
<p>And the earlier, but still great Colin Moock&#8217;s &#8220;ActionScript for Flash MX: The Definitive Guide&#8221; has the following:</p>
<p>Event-Based Asynchronous Code Execution<br />
<a href="http://www.adobe.com/devnet/flash/articles/actionscript.html" rel="nofollow">http://www.adobe.com/devnet/flash/articles/actionscript.html</a></p>
<p>Event-Based Asynchronous Code Execution<br />
&#8220;Some code does not execute in a predetermined sequence. Instead, it executes when the ActionScript interpreter notices that an event has occurred. Many events involve a user action, such as clicking the mouse, resizing the movie, or pressing a key. Other events happen without user intervention, such as a sound completing or an XML document loading. Just as the playhead entering a new frame executes synchronous code attached to the frame, events can cause event-based code to execute. Event-based code (code that executes in response to an event) is said to be executed asynchronously because the triggering of events can occur at arbitrary times.</p>
<p>hth,</p>
<p>g</p>
]]></content:encoded>
	</item>
</channel>
</rss>
