<?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: [AS3] Avoiding NULL Object Reference Error When Loading Module SWF</title>
	<atom:link href="http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/</link>
	<description>Flash UI Components</description>
	<lastBuildDate>Tue, 23 Aug 2011 08:29:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: bochelord</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-815</link>
		<dc:creator>bochelord</dc:creator>
		<pubDate>Fri, 29 Oct 2010 13:59:55 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-815</guid>
		<description>Thanks a lot for a clear and solving explanation!</description>
		<content:encoded><![CDATA[<p>Thanks a lot for a clear and solving explanation!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bmkhoa</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-791</link>
		<dc:creator>bmkhoa</dc:creator>
		<pubDate>Mon, 20 Sep 2010 02:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-791</guid>
		<description>Thanks very much sunny. It&#039;s really out of luck.
I also wish Adobe would let stage accessible from all, or unaccessible from all until the flash is fully created and added to stage.</description>
		<content:encoded><![CDATA[<p>Thanks very much sunny. It&#8217;s really out of luck.<br />
I also wish Adobe would let stage accessible from all, or unaccessible from all until the flash is fully created and added to stage.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunny</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-790</link>
		<dc:creator>sunny</dc:creator>
		<pubDate>Sat, 18 Sep 2010 14:51:45 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-790</guid>
		<description>@bmkhoa, I don&#039;t know of any workaround, and I actually don&#039;t think you can workaround this.  I mean theoretically a workaround is impossible since the stage object is going to be NULL in the constructor and if your module SWFs are doing stuff with the stage object in the constructor, I guess you are out of luck if you cannot change the code in the module SWFs.

Sorry I misunderstood your earlier question.  Yes, it is strange that running a SWF on its own and loading it into a host SWF yields different results.  However, think of it this way - when you run a SWF directly on its own, the top level display object is the top level class (so stage is not NULL) whereas loading a SWF as a module is a two step process (instantiating the class as a display object, then adding it as the child of the Loader object).

I wished Adobe would actually design the player API such that stage is always defined (it should, since there is only ever going to be just one stage).  Stage really should be a globally accessible object that always point to the top level display object, but unfortunately it isn&#039;t.</description>
		<content:encoded><![CDATA[<p>@bmkhoa, I don&#8217;t know of any workaround, and I actually don&#8217;t think you can workaround this.  I mean theoretically a workaround is impossible since the stage object is going to be NULL in the constructor and if your module SWFs are doing stuff with the stage object in the constructor, I guess you are out of luck if you cannot change the code in the module SWFs.</p>
<p>Sorry I misunderstood your earlier question.  Yes, it is strange that running a SWF on its own and loading it into a host SWF yields different results.  However, think of it this way &#8211; when you run a SWF directly on its own, the top level display object is the top level class (so stage is not NULL) whereas loading a SWF as a module is a two step process (instantiating the class as a display object, then adding it as the child of the Loader object).</p>
<p>I wished Adobe would actually design the player API such that stage is always defined (it should, since there is only ever going to be just one stage).  Stage really should be a globally accessible object that always point to the top level display object, but unfortunately it isn&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bmkhoa</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-789</link>
		<dc:creator>bmkhoa</dc:creator>
		<pubDate>Fri, 17 Sep 2010 06:40:13 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-789</guid>
		<description>If the flash is still unchanged, it access stage on constructor. Is there a way to workaround? I am stuck in this error, because I can not have all the third-party flashes recompiled!</description>
		<content:encoded><![CDATA[<p>If the flash is still unchanged, it access stage on constructor. Is there a way to workaround? I am stuck in this error, because I can not have all the third-party flashes recompiled!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunny</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-788</link>
		<dc:creator>sunny</dc:creator>
		<pubDate>Thu, 16 Sep 2010 09:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-788</guid>
		<description>run time errors like this are not shown in release versions of the flash player (but it does not mean the error does not occur).  debug standalone will still show the error.</description>
		<content:encoded><![CDATA[<p>run time errors like this are not shown in release versions of the flash player (but it does not mean the error does not occur).  debug standalone will still show the error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bmkhoa</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-787</link>
		<dc:creator>bmkhoa</dc:creator>
		<pubDate>Thu, 16 Sep 2010 08:40:13 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-787</guid>
		<description>Excuse me for my stupid question! Why the error does not occur if the flash run standalone? 

Even in standalone mode, in constructor context, the flash object still not fully created, so it is not added to stage, still get null reference to stage. Right?</description>
		<content:encoded><![CDATA[<p>Excuse me for my stupid question! Why the error does not occur if the flash run standalone? </p>
<p>Even in standalone mode, in constructor context, the flash object still not fully created, so it is not added to stage, still get null reference to stage. Right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rasmus</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-476</link>
		<dc:creator>Rasmus</dc:creator>
		<pubDate>Thu, 18 Mar 2010 16:05:05 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-476</guid>
		<description>thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you!! This was killing me - I was thinking about a career change!</description>
		<content:encoded><![CDATA[<p>thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you!! This was killing me &#8211; I was thinking about a career change!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Murdoch</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-440</link>
		<dc:creator>Murdoch</dc:creator>
		<pubDate>Mon, 21 Dec 2009 03:24:14 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-440</guid>
		<description>This is exactly what I was looking for. It was doing my head in. Another fix is putting all code on the 2nd frame of the loaded SWF but this approach is much more elegant and correct. My Flash IDE approach is below (all code on first frame of loaded SWF):

this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true )
function init(event:Event):void {
	trace(MovieClip(this.parent.parent));
       // calls to main timeline will now work
}</description>
		<content:encoded><![CDATA[<p>This is exactly what I was looking for. It was doing my head in. Another fix is putting all code on the 2nd frame of the loaded SWF but this approach is much more elegant and correct. My Flash IDE approach is below (all code on first frame of loaded SWF):</p>
<p>this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true )<br />
function init(event:Event):void {<br />
	trace(MovieClip(this.parent.parent));<br />
       // calls to main timeline will now work<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MicL</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-426</link>
		<dc:creator>MicL</dc:creator>
		<pubDate>Mon, 30 Nov 2009 15:30:25 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-426</guid>
		<description>Thanks for this post. Cleared things up for me :)</description>
		<content:encoded><![CDATA[<p>Thanks for this post. Cleared things up for me <img src='http://www.ghostwire.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Angelico</title>
		<link>http://www.ghostwire.com/blog/archives/as3-avoiding-null-object-reference-error-when-loading-module-swf/comment-page-1/#comment-410</link>
		<dc:creator>Alex Angelico</dc:creator>
		<pubDate>Tue, 27 Oct 2009 20:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://ghostwire.com/blog/?p=675#comment-410</guid>
		<description>Dear Sunny, THANK YOU VERY MUCH!!!!
I didn&#039;t had a clue how to solve this issue, and your solution is so simple and clear!!!</description>
		<content:encoded><![CDATA[<p>Dear Sunny, THANK YOU VERY MUCH!!!!<br />
I didn&#8217;t had a clue how to solve this issue, and your solution is so simple and clear!!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

