07Jan

[AS 3] Preloader -> flash.display.Loader and flash.display.LoaderInfo

1 comment so far

Package is flash.display and the public class Loader

The Loader class is used to load SWF, JPG, PNG, or GIF files and uses the load method to initiate loading.

I have been searching around for some AS 3 preloader code and have come up with this.. but for some reason I just can’t get it to work.. any ideas?

Update:
http://manewc.com/2008/01/08/as-3-update-preloader-flashdisplayloader-and-flashdisplayloaderinfo/

package
{
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.events.ProgressEvent;

	public class Loader extends Sprite {

		private var ldr:Loader = new Loader();

	 	var req:URLRequest = new URLRequest("logo.gif");

	 	ldr.load(req);

	 	ldr.contentLoaderInfo.addEventListener(Event.OPEN,open);
		ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progress);
		ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,result);

		function open(evt:Event):void
		{
			trace ("opening file");
		}

		function progress(evt:ProgressEvent):void
		{
			trace ("loaded: " + evt.bytesLoaded);
		}

		function result(evt:Event):void
		{
			addChild(ldr);
		}
	 }
}

Share/Save/Bookmark

Categories: Actionscript 3, Preloading

Monday, January 7th, 2008 at 10:52 am and is filed under Actionscript 3, Preloading. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “[AS 3] Preloader -> flash.display.Loader and flash.display.LoaderInfo”

  1. Posted by just browsing 8th January, 2008 at 8:32 am

    there may be an issue with using Loader as the class name.. maybe you should try

    public class LoaderScript extends Sprite

Leave a reply