Hello! I try to make my own simple preloader. I’ve read other topic, but couldn’t find answer. Once I’ve found code:
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
/**
* ...
* @author Calemb
*/
public class Main extends Sprite
{
private var myLoader:Loader = new Loader();
public function Main():void
{
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, laoderProgressHandler);
myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loaderErrorHandler);
var url:URLRequest = new URLRequest("Hospital.swf");
myLoader.load(url); // load the SWF file
}
public function loaderCompleteHandler(evt:Event):void
{
addChild(evt.currentTarget.content);
}
public function laoderProgressHandler(evt:ProgressEvent):void
{
trace(evt.bytesLoaded + " / " + evt.bytesTotal);
}
public function loaderErrorHandler(evt:IOErrorEvent):void
{
trace("LOAD ERR");
}
}
}
But when I run project(flashDevelop) there is load looping. When loader progress is 100%, then everything start again (evt.bytesLoaded is equal 0 again). Nothing is showed on screen.
This main class is only class in the project -> flashDevelop create it as new AS3 Project…
I start my AS3 trip only with FP…
Maybe someone now what I’m talking about and know how to help ?