Section 1
//Preloader (view.Preloader)
package view {
import flash.display.*;
public class Preloader extends Sprite {
public function Preloader(){
super();
}
public function setProgress(p:Number):void{
}
}
}//package view
Section 2
//Container (Container)
package {
import flash.events.*;
import flash.display.*;
import view.*;
import flash.net.*;
import flash.system.*;
public class Container extends Sprite {
private var loader:Loader;
private var preloader:Preloader;
public function Container(){
super();
preloader = new Preloader();
addChild(preloader);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onApplicationProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onApplicationLoaded);
loader.load(new URLRequest("Application.swf"), new LoaderContext(false, ApplicationDomain.currentDomain));
}
private function onApplicationLoaded(event:Event):void{
preloader.setProgress(1);
removeChild(preloader);
addChild(loader.content);
}
private function onApplicationProgress(event:ProgressEvent):void{
preloader.setProgress(((0.9 * event.bytesLoaded) / event.bytesTotal));
}
}
}//package