<?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: SWF to SWF Communication in FLASH CSx: how to call methods between swf files</title>
	<atom:link href="http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/</link>
	<description>Adobe, Actionscript, Flex, Flash, Air, FlashLite, scripts and tutorial</description>
	<pubDate>Fri, 18 May 2012 22:15:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cod3monk3y</title>
		<link>http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/comment-page-1/#comment-1590</link>
		<dc:creator>cod3monk3y</dc:creator>
		<pubDate>Sun, 05 Jun 2011 03:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.fabiobiondi.com/blog/?p=356#comment-1590</guid>
		<description>Very nice, clean code. I have a few notes to point out

1. be sure to use "loader.contentLoaderInfo" and NOT "loader.loaderInfo"

If you use "loaderInfo", on line 73 you will find that e.currentTarget.content is actually "Core". Using "contentLoaderInfo" will give you "Page" as expected.

2. Use namespaces or a new application domain

Since both your SWFs have the default package (none), all your code from the loaded SWF will be loaded into the loading SWF. If your main classes have the same name in both, there will be a name collision and your LOADED SWF will use the code from the LOADING SWF.

This can manifest in several ways, but usually just in massive amounts of confusion. If you try to load a SWF in your addedToStage handler, you'll find yourself in an infinite recursion.

The first solution is to use namespaces. This ensures that if you have any classes with the same names that there are no name collisions (and no infinite recursion, and no mysterious behaviors). This solution is acceptable. However, the classes that you load will NOT unload when your unload the loaded SWF. And if you don't control your LOADED (Page) SWFs, you can't guarantee the safety of your Core application.

The second (and better) solution is to use a new application domain for your loaded SWF. This completely isolates the code that you're loading, ensures there are no name collisions, and saves you a ton of headache. Your code then changes to this:

loader.load( new URLRequest("Page.swf"), new LoaderContext(false, new ApplicationDomain()));

Cheers,
cm</description>
		<content:encoded><![CDATA[<p>Very nice, clean code. I have a few notes to point out</p>
<p>1. be sure to use &#8220;loader.contentLoaderInfo&#8221; and NOT &#8220;loader.loaderInfo&#8221;</p>
<p>If you use &#8220;loaderInfo&#8221;, on line 73 you will find that e.currentTarget.content is actually &#8220;Core&#8221;. Using &#8220;contentLoaderInfo&#8221; will give you &#8220;Page&#8221; as expected.</p>
<p>2. Use namespaces or a new application domain</p>
<p>Since both your SWFs have the default package (none), all your code from the loaded SWF will be loaded into the loading SWF. If your main classes have the same name in both, there will be a name collision and your LOADED SWF will use the code from the LOADING SWF.</p>
<p>This can manifest in several ways, but usually just in massive amounts of confusion. If you try to load a SWF in your addedToStage handler, you&#8217;ll find yourself in an infinite recursion.</p>
<p>The first solution is to use namespaces. This ensures that if you have any classes with the same names that there are no name collisions (and no infinite recursion, and no mysterious behaviors). This solution is acceptable. However, the classes that you load will NOT unload when your unload the loaded SWF. And if you don&#8217;t control your LOADED (Page) SWFs, you can&#8217;t guarantee the safety of your Core application.</p>
<p>The second (and better) solution is to use a new application domain for your loaded SWF. This completely isolates the code that you&#8217;re loading, ensures there are no name collisions, and saves you a ton of headache. Your code then changes to this:</p>
<p>loader.load( new URLRequest(&#8221;Page.swf&#8221;), new LoaderContext(false, new ApplicationDomain()));</p>
<p>Cheers,<br />
cm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maurycy Zarzycki</title>
		<link>http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/comment-page-1/#comment-716</link>
		<dc:creator>Maurycy Zarzycki</dc:creator>
		<pubDate>Wed, 31 Mar 2010 14:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.fabiobiondi.com/blog/?p=356#comment-716</guid>
		<description>Pretty clean solution. I think this is the best thing you can do to make it work quickly and effectively, although I am also considering an event based solution but I guess one can settle at this too :).</description>
		<content:encoded><![CDATA[<p>Pretty clean solution. I think this is the best thing you can do to make it work quickly and effectively, although I am also considering an event based solution but I guess one can settle at this too :).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amsicora</title>
		<link>http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/comment-page-1/#comment-6</link>
		<dc:creator>amsicora</dc:creator>
		<pubDate>Wed, 19 Aug 2009 10:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.fabiobiondi.com/blog/?p=356#comment-6</guid>
		<description>Thank you very much, henceforth I will post only in English.
Bye</description>
		<content:encoded><![CDATA[<p>Thank you very much, henceforth I will post only in English.<br />
Bye</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabio Biondi</title>
		<link>http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/comment-page-1/#comment-5</link>
		<dc:creator>Fabio Biondi</dc:creator>
		<pubDate>Wed, 19 Aug 2009 09:49:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.fabiobiondi.com/blog/?p=356#comment-5</guid>
		<description>You are absolutly right!! 
&lt;em&gt;MovieClip &lt;/em&gt;was the best choice in this situation (i just used &lt;em&gt;Object &lt;/em&gt;to cover all the possible situations, i.e. if you load an swf inside a Sprite)

However thanx for your comment. It's the first one :) and sorry if i'm answering you in english but i'm trying to port my blog in this language (even if my English is not so good ; )

Fabio</description>
		<content:encoded><![CDATA[<p>You are absolutly right!!<br />
<em>MovieClip </em>was the best choice in this situation (i just used <em>Object </em>to cover all the possible situations, i.e. if you load an swf inside a Sprite)</p>
<p>However thanx for your comment. It&#8217;s the first one <img src='http://www.fabiobiondi.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> and sorry if i&#8217;m answering you in english but i&#8217;m trying to port my blog in this language (even if my English is not so good ; )</p>
<p>Fabio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amsicora</title>
		<link>http://www.fabiobiondi.com/blog/2009/08/swf-to-swf-communication-in-flash-csx-how-to-call-methods-between-swf-files/comment-page-1/#comment-4</link>
		<dc:creator>amsicora</dc:creator>
		<pubDate>Wed, 19 Aug 2009 09:33:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.fabiobiondi.com/blog/?p=356#comment-4</guid>
		<description>Ottimo tutorial, incredibilmente chiaro.
Tuttavia, mi sapresti dire perché nella riga 39 di Page.as hai usato
(root.loaderInfo.loader.root as Object).unloadSwf();
piuttosto che:
(root.loaderInfo.loader.root as MovieClip).unloadSwf();
dato che Page.as deriva proprio da MovieClip.

Ciao</description>
		<content:encoded><![CDATA[<p>Ottimo tutorial, incredibilmente chiaro.<br />
Tuttavia, mi sapresti dire perché nella riga 39 di Page.as hai usato<br />
(root.loaderInfo.loader.root as Object).unloadSwf();<br />
piuttosto che:<br />
(root.loaderInfo.loader.root as MovieClip).unloadSwf();<br />
dato che Page.as deriva proprio da MovieClip.</p>
<p>Ciao</p>
]]></content:encoded>
	</item>
</channel>
</rss>

