<?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>Tue, 07 Sep 2010 07:56:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-6530</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Tue, 11 May 2010 00:58:07 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-6530</guid>
		<description>@Booky, all the downloadable source files can be found on the &lt;a href="/downloads/" rel="nofollow"&gt;Downloads&lt;/a&gt; page. You can see all the pages, including Downloads, at the top of the right column/sidebar. You can also use the search box if you're looking for something specific. The Downloads are also mentioned in the Welcome sticky post that is always at the top of the page. I would have emailed you directly to try to help you further, but the email address you provided was unuseable (and unpleasant).

Not including a CD was O'Reilly's choice because it cuts $5 off the cost of the book.</description>
		<content:encoded><![CDATA[<p>@Booky, all the downloadable source files can be found on the <a href="/downloads/" rel="nofollow">Downloads</a> page. You can see all the pages, including Downloads, at the top of the right column/sidebar. You can also use the search box if you&#8217;re looking for something specific. The Downloads are also mentioned in the Welcome sticky post that is always at the top of the page. I would have emailed you directly to try to help you further, but the email address you provided was unuseable (and unpleasant).</p>
<p>Not including a CD was O&#8217;Reilly&#8217;s choice because it cuts $5 off the cost of the book.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Booky</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-6529</link>
		<dc:creator>Booky</dc:creator>
		<pubDate>Mon, 10 May 2010 22:57:16 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-6529</guid>
		<description>Where are the rest of the examples from chap 13? Maybe you should include a cd next time. I will not recommend your book. :[</description>
		<content:encoded><![CDATA[<p>Where are the rest of the examples from chap 13? Maybe you should include a cd next time. I will not recommend your book. :[</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5343</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Wed, 30 Dec 2009 17:14:19 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5343</guid>
		<description>@Aditya, the expanded source files have been replaced with CS3 versions. (Since the release of CS4, there is no guarantee that files on this site will be compatible with CS3.) Unfortunately, I won't be able to get to your other questions for some time.</description>
		<content:encoded><![CDATA[<p>@Aditya, the expanded source files have been replaced with CS3 versions. (Since the release of CS4, there is no guarantee that files on this site will be compatible with CS3.) Unfortunately, I won&#8217;t be able to get to your other questions for some time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aditya</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5336</link>
		<dc:creator>Aditya</dc:creator>
		<pubDate>Wed, 30 Dec 2009 12:41:07 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5336</guid>
		<description>@Rich
Can you please save the " Expanded AVM Bridging Example in CS3 format". the present ones cannot be opened in it.
Thanks</description>
		<content:encoded><![CDATA[<p>@Rich<br />
Can you please save the &#8221; Expanded AVM Bridging Example in CS3 format&#8221;. the present ones cannot be opened in it.<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aditya</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5220</link>
		<dc:creator>Aditya</dc:creator>
		<pubDate>Sat, 19 Dec 2009 06:13:57 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5220</guid>
		<description>@Rich
Great !. thats basically what i was trying for ,just to send a value from avm1 and print it avm2. 

The source is in cs4 format :(  . Can you please re save the files in CS3 format this would make it accessible to a larger audience.
      As i understand this connection is mainly for sending calling methods between the two. but is it possible to access stage objects of avm1 from avm2  using something like Movieclip(loader.content) or an equivalent .Ive tried that and got a inaccessible method error.

i guess you should change your original post to something like  2 way communication between avm1 and avm2.

Thanks</description>
		<content:encoded><![CDATA[<p>@Rich<br />
Great !. thats basically what i was trying for ,just to send a value from avm1 and print it avm2. </p>
<p>The source is in cs4 format <img src='http://www.learningactionscript3.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  . Can you please re save the files in CS3 format this would make it accessible to a larger audience.<br />
      As i understand this connection is mainly for sending calling methods between the two. but is it possible to access stage objects of avm1 from avm2  using something like Movieclip(loader.content) or an equivalent .Ive tried that and got a inaccessible method error.</p>
<p>i guess you should change your original post to something like  2 way communication between avm1 and avm2.</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-5183</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Tue, 15 Dec 2009 17:19:04 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5183</guid>
		<description>@Aditya, thanks for the kind words. To answer 1) I'd have to see your code and, unfortunately, I don't have time to troubleshoot. So, I created an updated example to show you what is required. I can think of two things you might be running into. First, you need a separate LC for send and received, and both have to be common to both avm1 and avm2. Second, in AS3, you need an LC client to process callbacks. All of this is in the commented code.

For 2), the only "sweeping" change (pun intended) is to use the unloadAndStop() method introduced in Flash Player 10. However, this won't work in Flash Player 9, so you'll have to add plugin detection. 

Good luck!</description>
		<content:encoded><![CDATA[<p>@Aditya, thanks for the kind words. To answer 1) I&#8217;d have to see your code and, unfortunately, I don&#8217;t have time to troubleshoot. So, I created an updated example to show you what is required. I can think of two things you might be running into. First, you need a separate LC for send and received, and both have to be common to both avm1 and avm2. Second, in AS3, you need an LC client to process callbacks. All of this is in the commented code.</p>
<p>For 2), the only &#8220;sweeping&#8221; change (pun intended) is to use the unloadAndStop() method introduced in Flash Player 10. However, this won&#8217;t work in Flash Player 9, so you&#8217;ll have to add plugin detection. </p>
<p>Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aditya</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5143</link>
		<dc:creator>Aditya</dc:creator>
		<pubDate>Sat, 12 Dec 2009 07:06:22 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-5143</guid>
		<description>Hi Rich

I have to say this is the Best ever simplest example explaining the use of local connection. Good Work!!!

1. in the same example i have tried to invoke a simple function in avm 2 called printNumber(num:Num) using the send method in avm on press of a button. like

&lt;pre class="code"&gt;
on (press)
{
	trace(" avm1 buttton clicked");
	avm2LC.send("avm2","printNumber",[331]);
}
&lt;/pre&gt;

but i dont get the sent number in avm2.  how do i do this.

2. when Unloading external as2 swf from as3 files the sound persists so i use a SoundMixer.StopAll() Method before i unload the as2 swf. 
But like you pointed out this is more of memory management n garbage collection issue besides sound persistance.
is there any better  steps to take from the as3 loader side to ensure proper and clean Unloading of as2 swf.

Thanks in Advance.</description>
		<content:encoded><![CDATA[<p>Hi Rich</p>
<p>I have to say this is the Best ever simplest example explaining the use of local connection. Good Work!!!</p>
<p>1. in the same example i have tried to invoke a simple function in avm 2 called printNumber(num:Num) using the send method in avm on press of a button. like</p>
<pre class="code">
on (press)
{
	trace(" avm1 buttton clicked");
	avm2LC.send("avm2","printNumber",[331]);
}
</pre>
<p>but i dont get the sent number in avm2.  how do i do this.</p>
<p>2. when Unloading external as2 swf from as3 files the sound persists so i use a SoundMixer.StopAll() Method before i unload the as2 swf.<br />
But like you pointed out this is more of memory management n garbage collection issue besides sound persistance.<br />
is there any better  steps to take from the as3 loader side to ensure proper and clean Unloading of as2 swf.</p>
<p>Thanks in Advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-4645</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Mon, 09 Nov 2009 17:15:11 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-4645</guid>
		<description>@Thomas, your instruction is happening too fast. The AVM1 file hasn't had time to connect to the &lt;span class="inlineas"&gt;LocalConnection&lt;/span&gt;. In your code above, your request is sent out before the SWF is even loaded. 

In your comment, you said you added it to an &lt;span class="inlineas"&gt;Event.COMPLETE&lt;/span&gt; listener. That worked for me, but also issued your 'failed' trace. The AVM1 file has just loaded but not yet had time to subscribe to the &lt;span class="inlineas"&gt;LocalConnection&lt;/span&gt;.

Just by what you've discussed here, what you're trying to do doesn't make sense to me. If you need something to happen right away, why not just let the AS2 file do it right away? If you need the AS2 file to function differently, under different circumstances, just use a Timer to delay the trigger of the &lt;span class="inlineas"&gt;LocalConnection&lt;/span&gt; call.

The following adds a timer and cleans up the script. This works fine:

&lt;pre class="code"&gt;
// code in the as3 fla
var avm2LC:LocalConnection = new LocalConnection();
avm2LC.addEventListener(StatusEvent.STATUS, onConnStatus);

var chargeur:Loader = new Loader();
addChild(chargeur);
chargeur.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);
chargeur.load(new URLRequest("intro1.swf"));

var tmr:Timer = new Timer(20,1);
tmr.addEventListener(TimerEvent.TIMER, callAVM1, false, 0, true);

function onLoaded(evt:Event):void {
   tmr.start();
}

function callAVM1(evt:TimerEvent):void {
   avm2LC.send("avm2", "pauseAnim");
   tmr.stop();
   tmr.removeEventListener(TimerEvent.TIMER, callAVM1);
   tmr = null;
   chargeur.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
}

function onConnStatus(evt:StatusEvent):void {
   switch (event.level) {
      case "status" :
         trace("LocalConnection.send() succeeded");
         break;
      case "error" :
         trace("LocalConnection.send() failed");
   }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@Thomas, your instruction is happening too fast. The AVM1 file hasn&#8217;t had time to connect to the <span class="inlineas">LocalConnection</span>. In your code above, your request is sent out before the SWF is even loaded. </p>
<p>In your comment, you said you added it to an <span class="inlineas">Event.COMPLETE</span> listener. That worked for me, but also issued your &#8216;failed&#8217; trace. The AVM1 file has just loaded but not yet had time to subscribe to the <span class="inlineas">LocalConnection</span>.</p>
<p>Just by what you&#8217;ve discussed here, what you&#8217;re trying to do doesn&#8217;t make sense to me. If you need something to happen right away, why not just let the AS2 file do it right away? If you need the AS2 file to function differently, under different circumstances, just use a Timer to delay the trigger of the <span class="inlineas">LocalConnection</span> call.</p>
<p>The following adds a timer and cleans up the script. This works fine:</p>
<pre class="code">
// code in the as3 fla
var avm2LC:LocalConnection = new LocalConnection();
avm2LC.addEventListener(StatusEvent.STATUS, onConnStatus);

var chargeur:Loader = new Loader();
addChild(chargeur);
chargeur.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);
chargeur.load(new URLRequest("intro1.swf"));

var tmr:Timer = new Timer(20,1);
tmr.addEventListener(TimerEvent.TIMER, callAVM1, false, 0, true);

function onLoaded(evt:Event):void {
   tmr.start();
}

function callAVM1(evt:TimerEvent):void {
   avm2LC.send("avm2", "pauseAnim");
   tmr.stop();
   tmr.removeEventListener(TimerEvent.TIMER, callAVM1);
   tmr = null;
   chargeur.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
}

function onConnStatus(evt:StatusEvent):void {
   switch (event.level) {
      case "status" :
         trace("LocalConnection.send() succeeded");
         break;
      case "error" :
         trace("LocalConnection.send() failed");
   }
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-4641</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Mon, 09 Nov 2009 14:43:34 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-4641</guid>
		<description>@Malecroso, the only thing I'm sure of is that an AVM1Movie can't load into layers, but you're not doing that. I see the same behavior you're seeing: only the first load works. The only thing that seems to work is removing the movie clip and starting over. That would cause an unpleasant transition, however. Despite your assertion to the contrary, I would recode in AS3. If you don't want to recode everything, just recode the image gallery. </description>
		<content:encoded><![CDATA[<p>@Malecroso, the only thing I&#8217;m sure of is that an AVM1Movie can&#8217;t load into layers, but you&#8217;re not doing that. I see the same behavior you&#8217;re seeing: only the first load works. The only thing that seems to work is removing the movie clip and starting over. That would cause an unpleasant transition, however. Despite your assertion to the contrary, I would recode in AS3. If you don&#8217;t want to recode everything, just recode the image gallery.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-4628</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Sun, 08 Nov 2009 21:06:50 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#comment-4628</guid>
		<description>Hello,

I don't understand a thing. I try to send an order from the as3 swf to the as2 swf like this :

&lt;pre class="code"&gt;
// code in the as3 fla
var avm2LC:LocalConnection = new LocalConnection();
avm2LC.addEventListener(StatusEvent.STATUS, onConnStatus);

var chargeur:Loader = new Loader();
chargeur.load(new URLRequest("intro1.swf"));
addChild(chargeur);

function onConnStatus(event:StatusEvent):void{
   switch (event.level) {
          case "status":
                trace("LocalConnection.send() succeeded");
                break;
          case "error":
                trace("LocalConnection.send() failed");
                break;
   }
}

avm2LC.send("avm2", "pauseAnim");


// code in the as2 fla
var avm2LC:LocalConnection = new LocalConnection();
avm2LC.connect("avm2");

avm2LC.pauseAnim = function():Void
{
	timeline.pause(); // Where timeline is a TimelineLite instance (greensock)
}

// end of code
&lt;/pre&gt;

The result is "LocalConnection.send() failed". I try already to listen the Event.COMPLETE on the Loader and then to send the order to the as2 swf but I have the same error.

Could you help me please ?

Thank you !

Tom</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I don&#8217;t understand a thing. I try to send an order from the as3 swf to the as2 swf like this :</p>
<pre class="code">
// code in the as3 fla
var avm2LC:LocalConnection = new LocalConnection();
avm2LC.addEventListener(StatusEvent.STATUS, onConnStatus);

var chargeur:Loader = new Loader();
chargeur.load(new URLRequest("intro1.swf"));
addChild(chargeur);

function onConnStatus(event:StatusEvent):void{
   switch (event.level) {
          case "status":
                trace("LocalConnection.send() succeeded");
                break;
          case "error":
                trace("LocalConnection.send() failed");
                break;
   }
}

avm2LC.send("avm2", "pauseAnim");

// code in the as2 fla
var avm2LC:LocalConnection = new LocalConnection();
avm2LC.connect("avm2");

avm2LC.pauseAnim = function():Void
{
	timeline.pause(); // Where timeline is a TimelineLite instance (greensock)
}

// end of code
</pre>
<p>The result is &#8220;LocalConnection.send() failed&#8221;. I try already to listen the Event.COMPLETE on the Loader and then to send the order to the as2 swf but I have the same error.</p>
<p>Could you help me please ?</p>
<p>Thank you !</p>
<p>Tom</p>
]]></content:encoded>
	</item>
</channel>
</rss>
