Saturday, May 17, 2008

ProxyLoader Class

With my latest project I had lots of external assets loading. I wanted to make sure people knew something was happening while an asset was loading and I didn't want to create a preloader everytime, in comes ProxyLoader.
ProxyLoader is simply a Sprite that takes care of loading the asset via a Loader, draws a preloader, and border. It then destroys the preloader after the asset has been loaded.
One feature I added to this Class is the ability to create any type of visual preloader using the IPreloadable interface. So you can have a text preloader of one type of asset and a Movieclip for another as long as it implements the interface.
You can use the class in a very similar fashion as Loader, but you need to pass a width and height argument.

var loader:ProxyLoader = new ProxyLoader(435, 250);
loader.load(new URLRequest("path.to.asset"));
addChild(loader);

If you want to see the methods I have posted some docs here. You can download the package here. Hope it helps someone out.

0 comments: