Skip to content


[AS 3] Loading an external .png, .gif, .jpg, .swf with Actionscript -> flash.display.Loader Class

Whenever you want to load an asset you will need to create a Loader object. You can use it to load another flash movie .swf or a bitmap.

Here is my LoadImage.as file:

package
{
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.net.URLRequest;

	public class LoadImage extends Sprite
	{
		public function LoadImage()
		{
			init();
		}

		private function init():void
		{
			var loader:Loader = new Loader();
			addChild(loader);
			loader.load(new URLRequest("/path/to/image/myimage.gif"));
		}
	}
}

Posted in Actionscript 3, Image Effects.


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Eamonn says

    hi there, I hadnt seen images loaded like this before, but it is a very nice way of doing it.

    My only question – once you’ve loaded the image, how do you have access to it: so you can like change smoothing, or change its size and so on? I thought maybe you can get access to it through the loader var, but i havent had any luck.

    Thanks.

  2. admin says

    Hi Eamonn,

    I decided to write up a constructor for you, you can view it in today’s post:

    http://manewc.com/2008/05/15/manipulate-an-loader-object/

    Let me know if this helps, if not I can look into more what you are trying to accomplish

    Morgan



Some HTML is OK

or, reply to this post via trackback.