I'm writing a preloader:
package {
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.text.TextField;
import flash.display.LoaderInfo;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.system.System;
public class Preloader extends Sprite {
private var t:TextField = new TextField();
private var ver:String = "1000";
public function Preloader() {
t.y = 570;
addChild( t );
t.text = ver;
addEventListener( Event.ADDED_TO_STAGE, init );
}
private function init( e:Event ):void {
this.root.loaderInfo.addEventListener( ProgressEvent.PROGRESS, onLoadingProgress );
this.root.loaderInfo.addEventListener( Event.COMPLETE, onLoadingCompleted );
// See if it's already completed
var percent:int = int( root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal );
if ( percent == 1 )
onLoadingCompleted();
}
private function onLoadingProgress( event:Event ):void {
var percent:int = int(root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal * 100);
t.text = "Loading.. " + percent + "%";
}
private function onLoadingCompleted( event:Event = null ):void {
root.loaderInfo.removeEventListener( ProgressEvent.PROGRESS, onLoadingProgress );
root.loaderInfo.removeEventListener( Event.COMPLETE, onLoadingCompleted );
var mainClass:Class = loaderInfo.applicationDomain.getDefinition("Main") as Class;
var main:DisplayObject = new mainClass() as DisplayObject;
parent.addChild( main );
parent.removeChild( this );
}
}
}
with this as the Main class:
package {
import flash.display.Sprite;
public class Main extends Sprite {
public function Main() {
}
}
}
so this is close to as barebones as I could make it.
However, it greets me with a:
ReferenceError: Error #1065: Variable Main is not defined.
at flash.system::ApplicationDomain/getDefinition()
at ...
I use frames.frame to insert Main already. I am compiling using ant and the linux SDK directly (mxmlc). Am I missing anything obvious?