<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Chapter 3 Document Classes</title>
	<link>http://www.learningactionscript3.com/2008/01/12/chapter-3-document-classes/</link>
	<description>A digital supplement for the O'Reilly book</description>
	<pubDate>Wed, 20 Aug 2008 13:14:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2008/01/12/chapter-3-document-classes/#comment-196</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Wed, 06 Aug 2008 13:47:42 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/12/chapter-3-document-classes/#comment-196</guid>
		<description>While it is possible, it's not recommended. There's no all-encompassing reason that says it can't be done, but it's confusing at best and disastrous at worst. Mixing the two realms can also cause problems that aren't always easily identifiable. Consider this simple example.

FLA
&lt;div class="code"&gt;
trace("timeline");
&lt;/div&gt;

DOCUMENT CLASS "Main"
&lt;div class="code"&gt;
package {

&#160;&#160;&#160;&#160;import flash.display.MovieClip;

&#160;&#160;&#160;&#160;public class Main extends MovieClip {

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public function Main() {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;trace("document class");
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
		
&#160;&#160;&#160;&#160;}
	
}
&lt;/div&gt;

The above will work. However, if you do nothing more than change the document class to extend &lt;span class="inlineas"&gt;Sprite&lt;/span&gt;, instead of &lt;span class="inlineas"&gt;MovieClip&lt;/span&gt;, you will see this error:
&lt;div class="alert"&gt;
Error 1180: Call to a possibly undefined method addFrameScript.
&lt;/div&gt;

Why? Because the document class takes precedence and Sprites have no frames. As a result, the timeline frame script can't be added. That's not clear, however, for a few reasons. First, &lt;span class="inlineas"&gt;addFrameScript()&lt;/span&gt; is undocumented, so it's hard to figure out what's going on. Second, tracing the parent of both the timeline and document class reveals "[object Stage]" in both cases, indicating that they are siblings. So why does the document class require frames?

In overly simplified terms, the document class "replaces the timeline" and the timeline script is being added to the "frame script of the document class." Even as I write this I cringe at the effectiveness and accuracy of that description, but even the awkwardness of describing what's going on emphasizes the point. Whenever possible, don't mix the timeline and document class.</description>
		<content:encoded><![CDATA[<p>While it is possible, it&#8217;s not recommended. There&#8217;s no all-encompassing reason that says it can&#8217;t be done, but it&#8217;s confusing at best and disastrous at worst. Mixing the two realms can also cause problems that aren&#8217;t always easily identifiable. Consider this simple example.</p>
<p>FLA</p>
<div class="code">
trace(&#8221;timeline&#8221;);
</div>
<p>DOCUMENT CLASS &#8220;Main&#8221;</p>
<div class="code">
package {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;import flash.display.MovieClip;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;public class Main extends MovieClip {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function Main() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&#8221;document class&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>}
</p></div>
<p>The above will work. However, if you do nothing more than change the document class to extend <span class="inlineas">Sprite</span>, instead of <span class="inlineas">MovieClip</span>, you will see this error:</p>
<div class="alert">
Error 1180: Call to a possibly undefined method addFrameScript.
</div>
<p>Why? Because the document class takes precedence and Sprites have no frames. As a result, the timeline frame script can&#8217;t be added. That&#8217;s not clear, however, for a few reasons. First, <span class="inlineas">addFrameScript()</span> is undocumented, so it&#8217;s hard to figure out what&#8217;s going on. Second, tracing the parent of both the timeline and document class reveals &#8220;[object Stage]&#8221; in both cases, indicating that they are siblings. So why does the document class require frames?</p>
<p>In overly simplified terms, the document class &#8220;replaces the timeline&#8221; and the timeline script is being added to the &#8220;frame script of the document class.&#8221; Even as I write this I cringe at the effectiveness and accuracy of that description, but even the awkwardness of describing what&#8217;s going on emphasizes the point. Whenever possible, don&#8217;t mix the timeline and document class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Edwards</title>
		<link>http://www.learningactionscript3.com/2008/01/12/chapter-3-document-classes/#comment-191</link>
		<dc:creator>Doug Edwards</dc:creator>
		<pubDate>Tue, 05 Aug 2008 18:08:43 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/12/chapter-3-document-classes/#comment-191</guid>
		<description>Can a person mix a document class with timeline AS3 code in the same Flash Movie?

Thanks.</description>
		<content:encoded><![CDATA[<p>Can a person mix a document class with timeline AS3 code in the same Flash Movie?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
