After a little tweaking, I got the preloader code to work, thanks for the comment in regards to my class naming convention!
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 Preloader extends Sprite {
private var ldr:Loader = new Loader();
public function Preloader()
{
ldr.load(new URLRequest("/path/to/my/image.jpg"));
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
{
trace ("fully loaded");
addChild(ldr);
}
}
}
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.