Hi,
I'm using Flash with the 'document class' pointing at my code. I'd
like to make a pre-loader so that users don't just get a blank-white
screen while the swf loads. I've had a go at trying to implement a
standard-preloader, but as I'm using the document class feature in
Flash, things mess up.
Some (cut-down) code to illustratate what I've got so far:
public class ddGame extends Sprite
{
[Embed(source="/../images/earth.jpg")] private var
EarthImage:Class;
private var earthBitmap:Bitmap = new EarthImage();
public var scene:Scene3D;
private var camera:Camera3D;
private var view:View3D;
public function ddGame()
{
// set up the stage
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
// Add resize event listener
//stage.addEventListener(Event.RESIZE, onResize);
// Load in the pre-loader movie clip
mLoader = new mPreLoader();
addChild(mLoader);
// Trigger updates
this.addEventListener(Event.ENTER_FRAME, loading);
// Initialise
init3D();
// Create the 3D objects
createScene();
// etc..
}
private function loading(e:Event):void
{
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
mLoader.loader_txt.text =
Math.floor((loaded/total)*100)+ "%";
if (total == loaded)
{
this.addEventListener(Event.ENTER_FRAME, loop);
}
}
}
I've done searches for how to do this online, but nothing has come up.
Any help appretiated,
Cheers,
Daniel.