Main

Код AS3:
package {
import flash.display.Sprite;
[SWF(width = "800", height = "600", frameRate = "30")]
/**
* @author SlavaRa
*/
[Frame(factoryClass="Preloader")]
public final class Main extends Sprite {
public function Main():void {
super();
}
}
}
Preloader

Код AS3:
package {
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.utils.getDefinitionByName;
/**
* @author SlavaRa
*/
public class Preloader extends MovieClip {
public function Preloader() {
super();
this.configureStage();
this.addListeners();
//TODO: this.showAsset();
}
private function configureStage():void {
super.stage.scaleMode = StageScaleMode.NO_SCALE;
super.stage.align = StageAlign.TOP_LEFT;
}
private function addListeners():void {
super.addEventListener(Event.ENTER_FRAME, this.onSuperEnterFrame);
super.loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.onIoError);
super.loaderInfo.addEventListener(ProgressEvent.PROGRESS, this.onProgress);
}
private function onSuperEnterFrame(event:Event):void {
if (super.currentFrame == super.totalFrames) {
super.currentFrame;
super.stop();
this.removeListeners();
//TODO: this.hideAsset();
this.startup();
}
}
private function onIoError(event:IOErrorEvent):void {
trace("error:", event.text);
}
private function onProgress(event:ProgressEvent):void {
//TODO: this.updateAsset();
}
private function removeListeners():void {
super.removeEventListener(Event.ENTER_FRAME, this.onSuperEnterFrame);
super.loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, this.onIoError);
super.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, this.onProgress);
}
private function startup():void {
const c:Class = getDefinitionByName("Main") as Class;
super.addChild(DisplayObject(new c()));
}
}
}