<?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: Be a good SWF citizen, listen for Event.UNLOAD</title>
	<atom:link href="http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/</link>
	<description>Josh Tynjala explores Flash, Flex, and ActionScript.</description>
	<lastBuildDate>Sat, 31 Jul 2010 02:55:11 -0400</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Adriana</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-68893</link>
		<dc:creator>Adriana</dc:creator>
		<pubDate>Sat, 08 May 2010 11:01:15 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-68893</guid>
		<description>Hi there, I have a similar problem like Francisco, let me explain.

I have a very large project, I have Menu who calls sub-menus (childs), and the sub-menus more sub-sub-menus(more childs), they all loads from swf files, ervery time i go to a submenu I want to clear the old swf and remove it from memory.

When I start navigating it runs ok, but while i go further in the navigation gets sloppier, here is the script I&#039;m using:

var unicoLoader=new Loader(); 
addChild(unicoLoader);
home_mc.b1_btn.addEventListener(MouseEvent.CLICK, menu1) 
home_mc.b2_btn .addEventListener(MouseEvent.CLICK, menu2)  


function menu1(e:Event){ 
		unicoLoader.unloadAndStop();
		removeChild(unicoLoader);
		unicoLoader = null;
		System.gc();
		if (unicoLoader == null){
		var unicoLoader = new Loader;
		addChild(unicoLoader);
		unicoLoader.load(new URLRequest(&quot;entorno.swf&quot;))
		}

} 
function menu2(e:Event){ 
		unicoLoader.unloadAndStop();
		removeChild(unicoLoader);
		unicoLoader = null;
		System.gc();
		if (unicoLoader == null){
		var unicoLoader = new Loader;
		addChild(unicoLoader);
		unicoLoader.load(new URLRequest(&quot;reactiva.swf&quot;))
		}
} 

Can anyone help me, I can&#039;t find the solution, it should work, but obvioulsly it doesn&#039;t!!!!, I&#039;ve been stucked from the last 5 days and y need to move on, thanks in advanced.</description>
		<content:encoded><![CDATA[<p>Hi there, I have a similar problem like Francisco, let me explain.</p>
<p>I have a very large project, I have Menu who calls sub-menus (childs), and the sub-menus more sub-sub-menus(more childs), they all loads from swf files, ervery time i go to a submenu I want to clear the old swf and remove it from memory.</p>
<p>When I start navigating it runs ok, but while i go further in the navigation gets sloppier, here is the script I&#8217;m using:</p>
<p>var unicoLoader=new Loader(); <br />
addChild(unicoLoader);<br />
home_mc.b1_btn.addEventListener(MouseEvent.CLICK, menu1) <br />
home_mc.b2_btn .addEventListener(MouseEvent.CLICK, menu2)  </p>
<p>function menu1(e:Event){ <br />
		unicoLoader.unloadAndStop();<br />
		removeChild(unicoLoader);<br />
		unicoLoader = null;<br />
		System.gc();<br />
		if (unicoLoader == null){<br />
		var unicoLoader = new Loader;<br />
		addChild(unicoLoader);<br />
		unicoLoader.load(new URLRequest(&#8220;entorno.swf&#8221;))<br />
		}</p>
<p>} <br />
function menu2(e:Event){ <br />
		unicoLoader.unloadAndStop();<br />
		removeChild(unicoLoader);<br />
		unicoLoader = null;<br />
		System.gc();<br />
		if (unicoLoader == null){<br />
		var unicoLoader = new Loader;<br />
		addChild(unicoLoader);<br />
		unicoLoader.load(new URLRequest(&#8220;reactiva.swf&#8221;))<br />
		}<br />
} </p>
<p>Can anyone help me, I can&#8217;t find the solution, it should work, but obvioulsly it doesn&#8217;t!!!!, I&#8217;ve been stucked from the last 5 days and y need to move on, thanks in advanced.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aditya</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-63966</link>
		<dc:creator>aditya</dc:creator>
		<pubDate>Tue, 09 Mar 2010 08:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-63966</guid>
		<description>very very Essential info.i didn&#039;t realist how essential since i started fixing bugs on integration issues. loading/unloading...
it does a whole lot of good for every one to ensure they clean up on their side.

thanks for the info</description>
		<content:encoded><![CDATA[<p>very very Essential info.i didn&#8217;t realist how essential since i started fixing bugs on integration issues. loading/unloading&#8230;<br />
it does a whole lot of good for every one to ensure they clean up on their side.</p>
<p>thanks for the info</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61919</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Wed, 02 Dec 2009 17:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61919</guid>
		<description>fivedots, you should call &lt;a href=&quot;http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Loader.html#unloadAndStop()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;unloadAndStop()&lt;/code&gt;&lt;/a&gt; on the Loader when you want the video to unload and to stop playing. Changing frames in your SWF isn&#039;t enough to make it stop.</description>
		<content:encoded><![CDATA[<p>fivedots, you should call <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Loader.html#unloadAndStop()" rel="nofollow"><code>unloadAndStop()</code></a> on the Loader when you want the video to unload and to stop playing. Changing frames in your SWF isn&#8217;t enough to make it stop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fivedots</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61917</link>
		<dc:creator>fivedots</dc:creator>
		<pubDate>Wed, 02 Dec 2009 13:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61917</guid>
		<description>Hey there. I have an embedded video from vimeo and when I go to the other frame sound still plays. As I suppose I have to remove the player. Can you help me, how to do that.

Theres my code: (besides, I&#039;m new on scripting so it would be  nice to have a fully explanation how to do that. 

&lt;pre&gt;stop();

import flash.system.Security;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent; 

var moogaloop:Sprite = new Sprite(); // the video player
var player_width:int=900;
var player_height:int=500;
var clip_id:int = 7520057;


function startLoad():void
{
	Security.allowDomain(&quot;bitcast.vimeo.com&quot;);	
	var v_loader:Loader = new Loader();
	var v_request = new URLRequest(&quot;http://bitcast.vimeo.com/vimeo/swf/moogaloop.swf?clip_id=&quot; + clip_id + &quot;&amp;server=vimeo.com&quot; + &quot;&amp;width=&quot; + player_width + &quot;&amp;height=&quot; + player_height + &quot;&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1&quot;);
	v_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
	v_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
	v_loader.load(v_request);
}

function onCompleteHandler(e:Event):void
{ 
	// Position the player where you want it
	moogaloop.x = 50;
	moogaloop.y = 60;
	moogaloop.addChild(e.currentTarget.content);
	
	// Create the mask for moogaloop
	var v_mask:Sprite = new Sprite();
	with( v_mask.graphics ) {
		beginFill(0x000000, 1);
		drawRect(moogaloop.x, moogaloop.y, player_width, player_height);
		endFill();
	}
	
	addChild(v_mask);
	moogaloop.mask = v_mask;
	
	addChild(moogaloop);
}

function onProgressHandler(e:ProgressEvent):void
{
	var percent:Number = e.bytesLoaded / e.bytesTotal;
	trace(percent);
}
 
startLoad();&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hey there. I have an embedded video from vimeo and when I go to the other frame sound still plays. As I suppose I have to remove the player. Can you help me, how to do that.</p>
<p>Theres my code: (besides, I&#8217;m new on scripting so it would be  nice to have a fully explanation how to do that. </p>
<pre>stop();

import flash.system.Security;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent; 

var moogaloop:Sprite = new Sprite(); // the video player
var player_width:int=900;
var player_height:int=500;
var clip_id:int = 7520057;

function startLoad():void
{
	Security.allowDomain("bitcast.vimeo.com");
	var v_loader:Loader = new Loader();
	var v_request = new URLRequest("http://bitcast.vimeo.com/vimeo/swf/moogaloop.swf?clip_id=" + clip_id + "&amp;server=vimeo.com" + "&amp;width=" + player_width + "&amp;height=" + player_height + "&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1");
	v_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
	v_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
	v_loader.load(v_request);
}

function onCompleteHandler(e:Event):void
{
	// Position the player where you want it
	moogaloop.x = 50;
	moogaloop.y = 60;
	moogaloop.addChild(e.currentTarget.content);

	// Create the mask for moogaloop
	var v_mask:Sprite = new Sprite();
	with( v_mask.graphics ) {
		beginFill(0x000000, 1);
		drawRect(moogaloop.x, moogaloop.y, player_width, player_height);
		endFill();
	}

	addChild(v_mask);
	moogaloop.mask = v_mask;

	addChild(moogaloop);
}

function onProgressHandler(e:ProgressEvent):void
{
	var percent:Number = e.bytesLoaded / e.bytesTotal;
	trace(percent);
}

startLoad();</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anndorian</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61787</link>
		<dc:creator>Anndorian</dc:creator>
		<pubDate>Wed, 28 Oct 2009 10:55:09 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61787</guid>
		<description>Thanks !</description>
		<content:encoded><![CDATA[<p>Thanks !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danilo Wanner</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61265</link>
		<dc:creator>Danilo Wanner</dc:creator>
		<pubDate>Tue, 11 Aug 2009 12:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61265</guid>
		<description>Hey, Thanks a Lot for the Info!

I am currently working on my portfolio and it came in really useful! thanks again.

Greetings</description>
		<content:encoded><![CDATA[<p>Hey, Thanks a Lot for the Info!</p>
<p>I am currently working on my portfolio and it came in really useful! thanks again.</p>
<p>Greetings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hitmen</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61115</link>
		<dc:creator>Hitmen</dc:creator>
		<pubDate>Tue, 14 Jul 2009 05:23:26 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61115</guid>
		<description>thanks for the information, I was googling ways to watch the memory usage of objects in flash and came across this. I will definitely implement this in my future projects.
Expect a decent traffic boost soon, I added it to stumbleupon.</description>
		<content:encoded><![CDATA[<p>thanks for the information, I was googling ways to watch the memory usage of objects in flash and came across this. I will definitely implement this in my future projects.<br />
Expect a decent traffic boost soon, I added it to stumbleupon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61101</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Tue, 07 Jul 2009 20:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61101</guid>
		<description>I have loaded a swf lets say at frame 12, but I want to unload and not see it at say frame 14. Here is how i loaded it. Can anyone help me unload it?

&lt;pre&gt;stop();

import com.jeroenwijering.events.*;
import com.jeroenwijering.player.*;
import com.jeroenwijering.plugins.*;
import com.jeroenwijering.utils.Configger;
import flash.display.MovieClip;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.net.URLRequest;

var view:Object;

var videoPlayer = new Loader();
videoPlayer.contentLoaderInfo.addEventListener(Event.COMPLETE, videoLoaded);
videoPlayer.load(new URLRequest(&#039;DemoPlayer/player-licensed.swf?volume=100&amp;image=image.jpg&amp;icons=false&#039;));

function videoLoaded( evt:Event ):void {
var ply = evt.target.content;
ply.addEventListener(&#039;READY&#039;,playerReady);

// customize flashvars via the ply.config object
ply.config.resizing = false; // leave this for custom width, height, x, and y
ply.config.file = &#039;my.mp3&#039;;
ply.config.height = 295;
ply.config.width = 622;
ply.config.skin = &#039;DemoPlayer/simple2.swf&#039;;

// position player on the stage
videoPlayer.x = 1;
videoPlayer.y = 19;

addChild(videoPlayer);
}

function playerReady(evt:Event=null) {
view = evt.target.view;
view.sendEvent(ViewEvent.PLAY);
view.sendEvent(ViewEvent.LOAD,evt.target.config);
};&lt;/pre&gt;

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>I have loaded a swf lets say at frame 12, but I want to unload and not see it at say frame 14. Here is how i loaded it. Can anyone help me unload it?</p>
<pre>stop();

import com.jeroenwijering.events.*;
import com.jeroenwijering.player.*;
import com.jeroenwijering.plugins.*;
import com.jeroenwijering.utils.Configger;
import flash.display.MovieClip;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.net.URLRequest;

var view:Object;

var videoPlayer = new Loader();
videoPlayer.contentLoaderInfo.addEventListener(Event.COMPLETE, videoLoaded);
videoPlayer.load(new URLRequest('DemoPlayer/player-licensed.swf?volume=100&amp;image=image.jpg&amp;icons=false'));

function videoLoaded( evt:Event ):void {
var ply = evt.target.content;
ply.addEventListener('READY',playerReady);

// customize flashvars via the ply.config object
ply.config.resizing = false; // leave this for custom width, height, x, and y
ply.config.file = 'my.mp3';
ply.config.height = 295;
ply.config.width = 622;
ply.config.skin = 'DemoPlayer/simple2.swf';

// position player on the stage
videoPlayer.x = 1;
videoPlayer.y = 19;

addChild(videoPlayer);
}

function playerReady(evt:Event=null) {
view = evt.target.view;
view.sendEvent(ViewEvent.PLAY);
view.sendEvent(ViewEvent.LOAD,evt.target.config);
};</pre>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61074</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Sat, 27 Jun 2009 20:34:51 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61074</guid>
		<description>A SWF cannot unload itself (in AS3 at least, AS2 provided a way to do it), let alone ask a parent SWF to unload.</description>
		<content:encoded><![CDATA[<p>A SWF cannot unload itself (in AS3 at least, AS2 provided a way to do it), let alone ask a parent SWF to unload.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: francisco</title>
		<link>http://joshblog.net/2009/04/23/unloading-child-swfs-in-flash/comment-page-1/#comment-61073</link>
		<dc:creator>francisco</dc:creator>
		<pubDate>Sat, 27 Jun 2009 19:53:24 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=577#comment-61073</guid>
		<description>I have a question that maybe someone could figure it out.
I have a Main.swf (parent) that calls a Secondary.swf (child), and i was wondering, it&#039;s any possiblity to unload the Main.swf (parent) from the Secondary.swf (child).

in simple terms, can a child swf unload his parent swf??

Im desperate!!

Thank you</description>
		<content:encoded><![CDATA[<p>I have a question that maybe someone could figure it out.<br />
I have a Main.swf (parent) that calls a Secondary.swf (child), and i was wondering, it&#8217;s any possiblity to unload the Main.swf (parent) from the Secondary.swf (child).</p>
<p>in simple terms, can a child swf unload his parent swf??</p>
<p>Im desperate!!</p>
<p>Thank you</p>
]]></content:encoded>
	</item>
</channel>
</rss>
