<?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: Sending Data from AVM2 to AVM1</title>
	<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/</link>
	<description>A digital supplement for the O'Reilly book</description>
	<pubDate>Wed, 20 Aug 2008 13:10:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Steve</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-110</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Mon, 09 Jun 2008 05:11:50 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-110</guid>
		<description>I'm interested in extending this example to control a number of dynamically loaded swfs. When dealing with two AVM1Movie instances, It seems that the first loaded AVM1Movie eats the LocalConnection event and blocks it from propagating to other listeners. Hey, no fair!

You can see this in action if you open up two browser windows of this page. The play/stop controls in each embedded movie will only affect the first loaded AVM1Movie instance loaded.

Pperhaps the way to do this is for the AVM1Movie to broadcast on a predetermined statically named LocalConnection to the AVM2 container, informing it of a dynamically (run-time) determined LocalConnection receiving channel name. The AVM2 container movie would have to keep track of each AVM1 instance and it's dynamic LocalConnection name for when it wants to send commands. It seems like an ugly solution.</description>
		<content:encoded><![CDATA[<p>I&#8217;m interested in extending this example to control a number of dynamically loaded swfs. When dealing with two AVM1Movie instances, It seems that the first loaded AVM1Movie eats the LocalConnection event and blocks it from propagating to other listeners. Hey, no fair!</p>
<p>You can see this in action if you open up two browser windows of this page. The play/stop controls in each embedded movie will only affect the first loaded AVM1Movie instance loaded.</p>
<p>Pperhaps the way to do this is for the AVM1Movie to broadcast on a predetermined statically named LocalConnection to the AVM2 container, informing it of a dynamically (run-time) determined LocalConnection receiving channel name. The AVM2 container movie would have to keep track of each AVM1 instance and it&#8217;s dynamic LocalConnection name for when it wants to send commands. It seems like an ugly solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-66</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Wed, 14 May 2008 03:15:47 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-66</guid>
		<description>@Manuel, can you describe what doesn't work? Which file? There is an AS2 file (avm1.fla) and AS3 file (avm2.fla). The AS2 portion of the demo is an animation that autoplays. Is it not playing on your machine?</description>
		<content:encoded><![CDATA[<p>@Manuel, can you describe what doesn&#8217;t work? Which file? There is an AS2 file (avm1.fla) and AS3 file (avm2.fla). The AS2 portion of the demo is an animation that autoplays. Is it not playing on your machine?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manuel</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-65</link>
		<dc:creator>Manuel</dc:creator>
		<pubDate>Wed, 14 May 2008 03:06:49 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-65</guid>
		<description>Hey Rich thanx for the post. The file you posted doesn't work with as2. I bet maybe it just needs a couple of tweaks. It's just to let you know</description>
		<content:encoded><![CDATA[<p>Hey Rich thanx for the post. The file you posted doesn&#8217;t work with as2. I bet maybe it just needs a couple of tweaks. It&#8217;s just to let you know</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-58</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Mon, 12 May 2008 21:18:03 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-58</guid>
		<description>@Alex: Not exactly. If you know which steps must be taken, you can do so from the loader. I tend to prefer doing this from the loadee, but you can do either, given the right information. The important thing is, there's a big difference between stopping each process and unloading the loader. You have to stop the sound from playing, stop all other processes I mentioned, then unload, then nullify. Just unloading doesn't do the job the way it did with AS2.

I'll try to get these posts up asap!</description>
		<content:encoded><![CDATA[<p>@Alex: Not exactly. If you know which steps must be taken, you can do so from the loader. I tend to prefer doing this from the loadee, but you can do either, given the right information. The important thing is, there&#8217;s a big difference between stopping each process and unloading the loader. You have to stop the sound from playing, stop all other processes I mentioned, then unload, then nullify. Just unloading doesn&#8217;t do the job the way it did with AS2.</p>
<p>I&#8217;ll try to get these posts up asap!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Drelles</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-57</link>
		<dc:creator>Alex Drelles</dc:creator>
		<pubDate>Mon, 12 May 2008 21:05:32 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-57</guid>
		<description>Congratulations and absolutely no need to apology.  I have 2 young ones myself.  I've been working in Flash for years and never posted a question to a forum, so getting a response is like internet magic.  

Quick question, on p 63 of the book you have a section titled Removing Objects from Memory, you essentially set ball=null to clear it from memory after removing it from the display list. I tried setting my loader to null after I remove it from the display list and it still plays the audio from the loaded swf. So when you say "In short, you need to stop everything you started before you unload...." the loaded swf must be responsible for it's own cleanup.

thanks again</description>
		<content:encoded><![CDATA[<p>Congratulations and absolutely no need to apology.  I have 2 young ones myself.  I&#8217;ve been working in Flash for years and never posted a question to a forum, so getting a response is like internet magic.  </p>
<p>Quick question, on p 63 of the book you have a section titled Removing Objects from Memory, you essentially set ball=null to clear it from memory after removing it from the display list. I tried setting my loader to null after I remove it from the display list and it still plays the audio from the loaded swf. So when you say &#8220;In short, you need to stop everything you started before you unload&#8230;.&#8221; the loaded swf must be responsible for it&#8217;s own cleanup.</p>
<p>thanks again</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-56</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Mon, 12 May 2008 20:22:49 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-56</guid>
		<description>@Alex: Yes, they will be going up this week. I'm to blame for their delay, and not for very professional reasons, I'm afraid. My wife and I just had a baby daughter and she arrived a week early. So, both the build up and the aftermath have thrown my schedule for a loop. Sorry about that!

In short, you need to stop everything you started before you unload. This is good practice anyway, but does require more diligence. For example, stop all sounds and videos, close any sound and video streams, stop all timers (a running timer can never be garbage collected), remove listeners (especially enter frame listeners), and then unload. 

That should enable your assets to be collected but, even then, you don't know when and have no control over the process. This is not a question for lingering sound playback of course, but rather for memory management. This, too, may not be an issue for you if your project is a get-in and get-out type of thing, but it's important for things like kiosks that run continuously.

If all goes well, we'll have the loading/unloading material live this week. Thanks!</description>
		<content:encoded><![CDATA[<p>@Alex: Yes, they will be going up this week. I&#8217;m to blame for their delay, and not for very professional reasons, I&#8217;m afraid. My wife and I just had a baby daughter and she arrived a week early. So, both the build up and the aftermath have thrown my schedule for a loop. Sorry about that!</p>
<p>In short, you need to stop everything you started before you unload. This is good practice anyway, but does require more diligence. For example, stop all sounds and videos, close any sound and video streams, stop all timers (a running timer can never be garbage collected), remove listeners (especially enter frame listeners), and then unload. </p>
<p>That should enable your assets to be collected but, even then, you don&#8217;t know when and have no control over the process. This is not a question for lingering sound playback of course, but rather for memory management. This, too, may not be an issue for you if your project is a get-in and get-out type of thing, but it&#8217;s important for things like kiosks that run continuously.</p>
<p>If all goes well, we&#8217;ll have the loading/unloading material live this week. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Drelles</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-55</link>
		<dc:creator>Alex Drelles</dc:creator>
		<pubDate>Mon, 12 May 2008 20:00:02 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-55</guid>
		<description>Any word on the loading/unloading series of posts?  I've been back and forth in the book trying to understand loading/unloading AS2 and AS3 swfs into an AS3 shell. They load fine, I just can't get them out of memory.  They are off the display list, but the audio track continues to play after I call the removeChild method. 

Great book by the way, I started with Essential ActionScript 3.0 and was overwhelmed.

thanks</description>
		<content:encoded><![CDATA[<p>Any word on the loading/unloading series of posts?  I&#8217;ve been back and forth in the book trying to understand loading/unloading AS2 and AS3 swfs into an AS3 shell. They load fine, I just can&#8217;t get them out of memory.  They are off the display list, but the audio track continues to play after I call the removeChild method. </p>
<p>Great book by the way, I started with Essential ActionScript 3.0 and was overwhelmed.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-46</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Wed, 16 Apr 2008 14:45:16 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-46</guid>
		<description>@Michael, yes you can, but it's not required. AS3/AS3 asset sets can communicate with each other without LocalConnection. There are lots of issues with loading and unloading AS3 assets, and we've been massaging a few posts about the topic for quite a while now. (We we're trying to get the definitive word on what we think is a bug in the Flash IDE, but we're going to post in the meantime, too.) 

For everyone's benefit, on Friday, we'll start the series and you'll be able to follow this thread through a few posts over the ensuing days. However, here's a quick discussion about AS3 loader/loadee arrangements. I caution you that this is just a discussion, a quick answer to your question, and won't have the clarity of a proper post. If you have any trouble with my context here, don't worry, the post will clear it all up and provide sample files. If you can muddle through this, however, it'll give you a jump start.

For this quick discussion, I'll assume you are using timeline code (it's a bit different with classes) and can successfully load a SWF, using the simple example at the top of page 285. Then, in the loaded SWF (called "toLoad" in the example), you can learn about the relationship between the parent and child this way. First, add "trace(parent);" to the "toLoad" file. When you test the loadee, the result will be the stage. When you test the loader you created earlier, the result will the be instance of the Loader class used to load the external SWF.

Next, add "trace(parent.parent);" to the loadee. This will show null when testing the loadee, because there is no parent higher than it's stage. But in the loader, this will reference the Loader instance's parent--in this case, the main timeline. You now have a path to talk to the loader from the loadee.

So, as an example, if you have a variable in the loader main timeline, called "loaderVar", for instance, you can get it's value this way (theoretically): "trace(parent.parent.loaderVar);" The only issue is that, in Strict Mode (which you should always use), the compiler doesn't know that loaderVar is a property (variable) of the movie clip (loader main timeline). So, you can explicitly cast the parent as a movie clip (again, assuming, as is true in this example, that the parent is the main timeline of the loader, not another display list child). To do this, all you need to do is add the MovieClip() casting method: "trace(MovieClip(parent.parent).loaderVar);" This way, the compiler knows that loaderVar is a property (variable) of the parent's parent you are trying to target.

The result is that you can get the variable value in the loader, from within the loadee. You can communicate both ways, trigger functions, etc. Remember that there is a lot to consider here--from how things change in classes, to identifying the parent of the loaded content (if, for example, it's not the main timeline), to properly unloading the content, to security issues if the loaded content isn't in the same domain, etc. For the most part, these are not inconsistent with AS2 issues, and are just added layers of concern that come with added complexity.

Stay tuned for the loading/unloading series (see the comment date for time-context) for a more clearly explained post and sample files.</description>
		<content:encoded><![CDATA[<p>@Michael, yes you can, but it&#8217;s not required. AS3/AS3 asset sets can communicate with each other without LocalConnection. There are lots of issues with loading and unloading AS3 assets, and we&#8217;ve been massaging a few posts about the topic for quite a while now. (We we&#8217;re trying to get the definitive word on what we think is a bug in the Flash IDE, but we&#8217;re going to post in the meantime, too.) </p>
<p>For everyone&#8217;s benefit, on Friday, we&#8217;ll start the series and you&#8217;ll be able to follow this thread through a few posts over the ensuing days. However, here&#8217;s a quick discussion about AS3 loader/loadee arrangements. I caution you that this is just a discussion, a quick answer to your question, and won&#8217;t have the clarity of a proper post. If you have any trouble with my context here, don&#8217;t worry, the post will clear it all up and provide sample files. If you can muddle through this, however, it&#8217;ll give you a jump start.</p>
<p>For this quick discussion, I&#8217;ll assume you are using timeline code (it&#8217;s a bit different with classes) and can successfully load a SWF, using the simple example at the top of page 285. Then, in the loaded SWF (called &#8220;toLoad&#8221; in the example), you can learn about the relationship between the parent and child this way. First, add &#8220;trace(parent);&#8221; to the &#8220;toLoad&#8221; file. When you test the loadee, the result will be the stage. When you test the loader you created earlier, the result will the be instance of the Loader class used to load the external SWF.</p>
<p>Next, add &#8220;trace(parent.parent);&#8221; to the loadee. This will show null when testing the loadee, because there is no parent higher than it&#8217;s stage. But in the loader, this will reference the Loader instance&#8217;s parent&#8211;in this case, the main timeline. You now have a path to talk to the loader from the loadee.</p>
<p>So, as an example, if you have a variable in the loader main timeline, called &#8220;loaderVar&#8221;, for instance, you can get it&#8217;s value this way (theoretically): &#8220;trace(parent.parent.loaderVar);&#8221; The only issue is that, in Strict Mode (which you should always use), the compiler doesn&#8217;t know that loaderVar is a property (variable) of the movie clip (loader main timeline). So, you can explicitly cast the parent as a movie clip (again, assuming, as is true in this example, that the parent is the main timeline of the loader, not another display list child). To do this, all you need to do is add the MovieClip() casting method: &#8220;trace(MovieClip(parent.parent).loaderVar);&#8221; This way, the compiler knows that loaderVar is a property (variable) of the parent&#8217;s parent you are trying to target.</p>
<p>The result is that you can get the variable value in the loader, from within the loadee. You can communicate both ways, trigger functions, etc. Remember that there is a lot to consider here&#8211;from how things change in classes, to identifying the parent of the loaded content (if, for example, it&#8217;s not the main timeline), to properly unloading the content, to security issues if the loaded content isn&#8217;t in the same domain, etc. For the most part, these are not inconsistent with AS2 issues, and are just added layers of concern that come with added complexity.</p>
<p>Stay tuned for the loading/unloading series (see the comment date for time-context) for a more clearly explained post and sample files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Johnson</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-44</link>
		<dc:creator>Michael Johnson</dc:creator>
		<pubDate>Wed, 16 Apr 2008 04:42:32 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-44</guid>
		<description>Can you use LocalConnection to communicate between two swfs that are Actionscript 3.0? I'm trying to get an externally loaded swf to communicate with the main timeline so that I can close the loaded swf. Is that possible using LocalConnection?</description>
		<content:encoded><![CDATA[<p>Can you use LocalConnection to communicate between two swfs that are Actionscript 3.0? I&#8217;m trying to get an externally loaded swf to communicate with the main timeline so that I can close the loaded swf. Is that possible using LocalConnection?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fajar Sylvana</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-33</link>
		<dc:creator>Fajar Sylvana</dc:creator>
		<pubDate>Sun, 02 Mar 2008 18:09:17 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-33</guid>
		<description>Thanks Rich for the answer,
by the way do you know i'm dying to have your book. wow.. it's so hard to get your book in Asean Country if you know that. and i have to go to the Singapore again next month, just to buy your book.. phew, but for now i'm just learning with the AS3 Documentation(not much helping, but thats not Bad). hey maybe you can help me with a code. i'm already hopeless doing an LC. what i'm gonna do is, i wanna made a first swf just for a button control and the other swf is for a Movie(i'm just loading an swf Movie inside second swf) what that apps gonna do is, when you click the Button on first swf and the Movie on second swf is appear.. Thats it.. simple concept right.. but it's hard to do(for me).. can you give me a code Example Rich, please Help me with this one? Thanks for Everything !

PS: i'm gonna have your Book someday.. i will..</description>
		<content:encoded><![CDATA[<p>Thanks Rich for the answer,<br />
by the way do you know i&#8217;m dying to have your book. wow.. it&#8217;s so hard to get your book in Asean Country if you know that. and i have to go to the Singapore again next month, just to buy your book.. phew, but for now i&#8217;m just learning with the AS3 Documentation(not much helping, but thats not Bad). hey maybe you can help me with a code. i&#8217;m already hopeless doing an LC. what i&#8217;m gonna do is, i wanna made a first swf just for a button control and the other swf is for a Movie(i&#8217;m just loading an swf Movie inside second swf) what that apps gonna do is, when you click the Button on first swf and the Movie on second swf is appear.. Thats it.. simple concept right.. but it&#8217;s hard to do(for me).. can you give me a code Example Rich, please Help me with this one? Thanks for Everything !</p>
<p>PS: i&#8217;m gonna have your Book someday.. i will..</p>
]]></content:encoded>
	</item>
</channel>
</rss>
