<?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: How to Load External Images in Actionscript 3.0</title>
	<atom:link href="http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/</link>
	<description>Advanced Flash and Actionscript 3 by Andrew Christensen</description>
	<lastBuildDate>Wed, 08 Feb 2012 21:08:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Mihai Petrica</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-694</link>
		<dc:creator>Mihai Petrica</dc:creator>
		<pubDate>Wed, 08 Feb 2012 21:08:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-694</guid>
		<description>Thank you much, very useful for us.</description>
		<content:encoded><![CDATA[<p>Thank you much, very useful for us.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. Mike Reddy</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-606</link>
		<dc:creator>Dr. Mike Reddy</dc:creator>
		<pubDate>Tue, 16 Aug 2011 15:32:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-606</guid>
		<description>Just a correction:

Andrew Christiensen said:

&quot;Also, here are a few great tutorials on loading/parsing XML:
http://www.gotoandlearn.com/play?id=64
http://www.gotoandlearn.com/play?id=65&quot;

but the tutorials have now moved to:

http://www.gotoandlearn.com/play.php?id=64
and
http://www.gotoandlearn.com/play.php?id=65
respectively</description>
		<content:encoded><![CDATA[<p>Just a correction:</p>
<p>Andrew Christiensen said:</p>
<p>&#8220;Also, here are a few great tutorials on loading/parsing XML:<br />
<a href="http://www.gotoandlearn.com/play?id=64" rel="nofollow">http://www.gotoandlearn.com/play?id=64</a><br />
<a href="http://www.gotoandlearn.com/play?id=65" rel="nofollow">http://www.gotoandlearn.com/play?id=65</a>&#8221;</p>
<p>but the tutorials have now moved to:</p>
<p><a href="http://www.gotoandlearn.com/play.php?id=64" rel="nofollow">http://www.gotoandlearn.com/play.php?id=64</a><br />
and<br />
<a href="http://www.gotoandlearn.com/play.php?id=65" rel="nofollow">http://www.gotoandlearn.com/play.php?id=65</a><br />
respectively</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Celestale</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-583</link>
		<dc:creator>Celestale</dc:creator>
		<pubDate>Fri, 06 May 2011 07:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-583</guid>
		<description>how to resize the image inside flash?</description>
		<content:encoded><![CDATA[<p>how to resize the image inside flash?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jluisfg</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-581</link>
		<dc:creator>jluisfg</dc:creator>
		<pubDate>Wed, 13 Apr 2011 15:30:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-581</guid>
		<description>Thanks, worked excelent!</description>
		<content:encoded><![CDATA[<p>Thanks, worked excelent!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-580</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 06 Apr 2011 15:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-580</guid>
		<description>I&#039;m more of a designer than a coder, but I&#039;ve decided to jump into Actionscript3.  Your loader works great.  Of course it continues to run when I change frames and I have attempted to construct an onexitFrame listener connected to a remove.child... but I don&#039;t yet have the feel.  Can you give me a boost?</description>
		<content:encoded><![CDATA[<p>I&#8217;m more of a designer than a coder, but I&#8217;ve decided to jump into Actionscript3.  Your loader works great.  Of course it continues to run when I change frames and I have attempted to construct an onexitFrame listener connected to a remove.child&#8230; but I don&#8217;t yet have the feel.  Can you give me a boost?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sammi</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-568</link>
		<dc:creator>Sammi</dc:creator>
		<pubDate>Wed, 09 Mar 2011 19:05:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-568</guid>
		<description>Thanks for replying, Andrew.
I&#039;m able to load in the texts, but unable to load in the external images.  Maybe you can help walk me through the logic? I&#039;ve noted where I get lost.  Thanks!

package proj 
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.MovieClip;
	import flash.display.Loader;
	import flash.net.URLRequest;
	import flash.display.Bitmap;


	public class DisplayTextsImages extends MovieClip {
		
		public var myArr:Array = [&#039;Monday&#039;, &#039;Tuesday&#039;, &#039;Wednesday&#039;, &#039;Thursday&#039;];
		
		public var imgLoader:Loader;
		public var imgRequest:URLRequest;
		public var image:Bitmap;
		
		public var imgHolder:MovieClip;
				
		public function DisplayTextsImages():void {
		
			for ( var i:Number = 0; i &lt; 8; i++ ) 
			{
				this[ &#039;btn&#039; + i  ].buttonMode = true;
				this[ &#039;btn&#039; + i  ].id = i;
				this[ &#039;btn&#039; + i  ].addEventListener(MouseEvent.CLICK, onClick);
				this[ &#039;btn&#039; + i  ].addEventListener(MouseEvent.ROLL_OVER, onClick);
				this[ &#039;btn&#039; + i  ].addEventListener(MouseEvent.ROLL_OUT, onClick);
			}
					
			loadImg();
			
		}
		
		public function onClick (e:MouseEvent):void 
		{
			if (e.type == &#039;rollOver&#039;) e.target.alpha = .5
			else if (e.type==&#039;rollOut&#039;) e.target.alpha= 1
			else if (e.type==&#039;click&#039;) 
			{	
                                // I&#039;m lost here
			        txt.text= myArr[e.target.id];
				loadImg(e.target.id);
			}
		}
		
		public function loadImg():void 
		{
			var imgURL:String = &#039;_images/&#039;;    // I&#039;m lost here

			imgLoader = new Loader();
			imgLoader.load(new URLRequest(imgURL));
			
			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);			
		}
		
		public function imgLoaded(e:Event):void 
		{
			var image = new Bitmap();
			image = e.target.content;
			
                        imgHolder = new  MovieClip();
			addChild(imgHolder);
			imgHolder.x = 200;
			imgHolder.y = 30;
			imgHolder.addChild(image);
		}
		
	}
}</description>
		<content:encoded><![CDATA[<p>Thanks for replying, Andrew.<br />
I&#8217;m able to load in the texts, but unable to load in the external images.  Maybe you can help walk me through the logic? I&#8217;ve noted where I get lost.  Thanks!</p>
<p>package proj<br />
{<br />
	import flash.events.Event;<br />
	import flash.events.MouseEvent;<br />
	import flash.display.MovieClip;<br />
	import flash.display.Loader;<br />
	import flash.net.URLRequest;<br />
	import flash.display.Bitmap;</p>
<p>	public class DisplayTextsImages extends MovieClip {</p>
<p>		public var myArr:Array = ['Monday', 'Tuesday', 'Wednesday', 'Thursday'];</p>
<p>		public var imgLoader:Loader;<br />
		public var imgRequest:URLRequest;<br />
		public var image:Bitmap;</p>
<p>		public var imgHolder:MovieClip;</p>
<p>		public function DisplayTextsImages():void {</p>
<p>			for ( var i:Number = 0; i &lt; 8; i++ )<br />
			{<br />
				this[ &#039;btn&#039; + i  ].buttonMode = true;<br />
				this[ &#039;btn&#039; + i  ].id = i;<br />
				this[ &#039;btn&#039; + i  ].addEventListener(MouseEvent.CLICK, onClick);<br />
				this[ &#039;btn&#039; + i  ].addEventListener(MouseEvent.ROLL_OVER, onClick);<br />
				this[ &#039;btn&#039; + i  ].addEventListener(MouseEvent.ROLL_OUT, onClick);<br />
			}</p>
<p>			loadImg();</p>
<p>		}</p>
<p>		public function onClick (e:MouseEvent):void<br />
		{<br />
			if (e.type == &#039;rollOver&#039;) e.target.alpha = .5<br />
			else if (e.type==&#039;rollOut&#039;) e.target.alpha= 1<br />
			else if (e.type==&#039;click&#039;)<br />
			{<br />
                                // I&#039;m lost here<br />
			        txt.text= myArr[e.target.id];<br />
				loadImg(e.target.id);<br />
			}<br />
		}</p>
<p>		public function loadImg():void<br />
		{<br />
			var imgURL:String = &#039;_images/&#039;;    // I&#039;m lost here</p>
<p>			imgLoader = new Loader();<br />
			imgLoader.load(new URLRequest(imgURL));</p>
<p>			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);<br />
		}</p>
<p>		public function imgLoaded(e:Event):void<br />
		{<br />
			var image = new Bitmap();<br />
			image = e.target.content;</p>
<p>                        imgHolder = new  MovieClip();<br />
			addChild(imgHolder);<br />
			imgHolder.x = 200;<br />
			imgHolder.y = 30;<br />
			imgHolder.addChild(image);<br />
		}</p>
<p>	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Christensen</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-563</link>
		<dc:creator>Andrew Christensen</dc:creator>
		<pubDate>Wed, 09 Mar 2011 01:27:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-563</guid>
		<description>Sammi,
Your array holding image urls would be hard coded. Then just run a loop through the array and load each array value using the code from the tutorial.</description>
		<content:encoded><![CDATA[<p>Sammi,<br />
Your array holding image urls would be hard coded. Then just run a loop through the array and load each array value using the code from the tutorial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sammi</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-562</link>
		<dc:creator>Sammi</dc:creator>
		<pubDate>Tue, 08 Mar 2011 17:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-562</guid>
		<description>Hi:

First , Thanks for posting this tutorial!

Second, what if i want to load more than one images using an array and not using xml file?
How am  i going about doing that?</description>
		<content:encoded><![CDATA[<p>Hi:</p>
<p>First , Thanks for posting this tutorial!</p>
<p>Second, what if i want to load more than one images using an array and not using xml file?<br />
How am  i going about doing that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-553</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Tue, 08 Feb 2011 18:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-553</guid>
		<description>This is my class with your code incorporated:

package {
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.text.TextField;
	import flash.events.*;
	import flash.net.*;

	public class Content extends MovieClip {

		public var projType:TextField;
		private var imgFrame:Sprite;
		private var imgLoader:Loader;

		public function Content(txt) {

			imgFrame = new Sprite();
			imgFrame.graphics.lineStyle(1, 0x2C2F43, .3);
			imgFrame.graphics.moveTo(0, 0);
			imgFrame.graphics.lineTo(0, 150);
			imgFrame.graphics.lineTo(270, 150);
			imgFrame.graphics.lineTo(270, 0);
			imgFrame.graphics.lineTo(0, 0);
			addChild(imgFrame);

			projType = new TextField();
			projType.autoSize=&quot;left&quot;;
			projType.height=26;
			projType.htmlText=txt;
			projType.x=imgFrame.x;
			projType.y=imgFrame.y+imgFrame.height;
			addChild(projType);

			var imgLoader:Loader = new Loader();
			imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);

			var fileRequest:URLRequest=new URLRequest(&quot;assets/jpg/temp03.jpg&quot;);
			imgLoader.load(fileRequest);

		}
		public function onProgressStatus(e:ProgressEvent) {
			// this is where progress will be monitored     
			trace(e.bytesLoaded, e.bytesTotal);
		}

		public function onLoaderReady(e:Event) {
			// the image is now loaded, so let&#039;s add it to the display tree!     
			addChild(imgLoader);
		}
	}
}

I get the following error when I run it:

TypeError: Error #2007: Parameter child must be non-null.
	at flash.display::DisplayObjectContainer/addChild()
	at Content/onLoaderReady()

I&#039;m guessing I need to add the child onto an existing mc? I&#039;m a little lost..</description>
		<content:encoded><![CDATA[<p>This is my class with your code incorporated:</p>
<p>package {<br />
	import flash.display.MovieClip;<br />
	import flash.display.Sprite;<br />
	import flash.display.Loader;<br />
	import flash.text.TextField;<br />
	import flash.events.*;<br />
	import flash.net.*;</p>
<p>	public class Content extends MovieClip {</p>
<p>		public var projType:TextField;<br />
		private var imgFrame:Sprite;<br />
		private var imgLoader:Loader;</p>
<p>		public function Content(txt) {</p>
<p>			imgFrame = new Sprite();<br />
			imgFrame.graphics.lineStyle(1, 0x2C2F43, .3);<br />
			imgFrame.graphics.moveTo(0, 0);<br />
			imgFrame.graphics.lineTo(0, 150);<br />
			imgFrame.graphics.lineTo(270, 150);<br />
			imgFrame.graphics.lineTo(270, 0);<br />
			imgFrame.graphics.lineTo(0, 0);<br />
			addChild(imgFrame);</p>
<p>			projType = new TextField();<br />
			projType.autoSize=&#8221;left&#8221;;<br />
			projType.height=26;<br />
			projType.htmlText=txt;<br />
			projType.x=imgFrame.x;<br />
			projType.y=imgFrame.y+imgFrame.height;<br />
			addChild(projType);</p>
<p>			var imgLoader:Loader = new Loader();<br />
			imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);<br />
			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);</p>
<p>			var fileRequest:URLRequest=new URLRequest(&#8220;assets/jpg/temp03.jpg&#8221;);<br />
			imgLoader.load(fileRequest);</p>
<p>		}<br />
		public function onProgressStatus(e:ProgressEvent) {<br />
			// this is where progress will be monitored<br />
			trace(e.bytesLoaded, e.bytesTotal);<br />
		}</p>
<p>		public function onLoaderReady(e:Event) {<br />
			// the image is now loaded, so let&#8217;s add it to the display tree!<br />
			addChild(imgLoader);<br />
		}<br />
	}<br />
}</p>
<p>I get the following error when I run it:</p>
<p>TypeError: Error #2007: Parameter child must be non-null.<br />
	at flash.display::DisplayObjectContainer/addChild()<br />
	at Content/onLoaderReady()</p>
<p>I&#8217;m guessing I need to add the child onto an existing mc? I&#8217;m a little lost..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-516</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Wed, 19 Jan 2011 06:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-516</guid>
		<description>Great tutorial! It&#039;s proving very useful so far.</description>
		<content:encoded><![CDATA[<p>Great tutorial! It&#8217;s proving very useful so far.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Christensen</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-388</link>
		<dc:creator>Andrew Christensen</dc:creator>
		<pubDate>Wed, 20 Oct 2010 23:50:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-388</guid>
		<description>Fred,
as2:
You can use the swapDepths() method

as3:
Use the setChildIndex() method or addChildAt() method. 
</description>
		<content:encoded><![CDATA[<p>Fred,<br />
as2:<br />
You can use the swapDepths() method</p>
<p>as3:<br />
Use the setChildIndex() method or addChildAt() method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fred</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-387</link>
		<dc:creator>fred</dc:creator>
		<pubDate>Wed, 20 Oct 2010 22:33:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-387</guid>
		<description>Is their a way to adjust the display order of the image.

I want the image to be displayed between objects in my scene.

you can see the URL here:
http://stage.indentstudios.com/cinerama/cinerama_header_v1.html</description>
		<content:encoded><![CDATA[<p>Is their a way to adjust the display order of the image.</p>
<p>I want the image to be displayed between objects in my scene.</p>
<p>you can see the URL here:<br />
<a href="http://stage.indentstudios.com/cinerama/cinerama_header_v1.html" rel="nofollow">http://stage.indentstudios.com/cinerama/cinerama_header_v1.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Christensen</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-366</link>
		<dc:creator>Andrew Christensen</dc:creator>
		<pubDate>Thu, 05 Aug 2010 22:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-366</guid>
		<description>Spettie,
No problem. You could load an external XML playlist file after the flash movie loads that holds the information of what external files to load when and also pass in their respective width/height/etc properties. That way instead of trying to access those properties from the Loader object you can parse them out from the XML file before any of the files are loaded.

Here is a quick tutorial on doing something similar to this: http://www.thetechlabs.com/tutorials/xml/create-a-as3-slideshow-with-xml/</description>
		<content:encoded><![CDATA[<p>Spettie,<br />
No problem. You could load an external XML playlist file after the flash movie loads that holds the information of what external files to load when and also pass in their respective width/height/etc properties. That way instead of trying to access those properties from the Loader object you can parse them out from the XML file before any of the files are loaded.</p>
<p>Here is a quick tutorial on doing something similar to this: <a href="http://www.thetechlabs.com/tutorials/xml/create-a-as3-slideshow-with-xml/" rel="nofollow">http://www.thetechlabs.com/tutorials/xml/create-a-as3-slideshow-with-xml/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spettie</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-365</link>
		<dc:creator>Spettie</dc:creator>
		<pubDate>Thu, 05 Aug 2010 21:15:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-365</guid>
		<description>Thanks Andrew, You are right on having to wait for the metadata to be loaded. I had to get the width after the load of the image, but it does work. thanks again, you the man.</description>
		<content:encoded><![CDATA[<p>Thanks Andrew, You are right on having to wait for the metadata to be loaded. I had to get the width after the load of the image, but it does work. thanks again, you the man.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Christensen</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/comment-page-1/#comment-364</link>
		<dc:creator>Andrew Christensen</dc:creator>
		<pubDate>Thu, 05 Aug 2010 20:49:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.728media.com/?p=222#comment-364</guid>
		<description>Spettie,
You would access the width property of your Loader object that is loading the image. So if bg_mc2 is your Loader instance you would do &quot;bg_mc2.width&quot; to get the width of the external image. You could also try accessing the content property of the Loader object to get the actual image file dimensions by using &quot;bg_mc2.content.width&quot;. The content object may return different results based on the load progress of your object. I&#039;m not sure if you can access a Loader object&#039;s width/height properties correctly immediately after load starts or until enough metadata has been loaded.</description>
		<content:encoded><![CDATA[<p>Spettie,<br />
You would access the width property of your Loader object that is loading the image. So if bg_mc2 is your Loader instance you would do &#8220;bg_mc2.width&#8221; to get the width of the external image. You could also try accessing the content property of the Loader object to get the actual image file dimensions by using &#8220;bg_mc2.content.width&#8221;. The content object may return different results based on the load progress of your object. I&#8217;m not sure if you can access a Loader object&#8217;s width/height properties correctly immediately after load starts or until enough metadata has been loaded.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

