PDA

View Full Version : stage and preloader problem



myoreo
August 15th, 2009, 03:55 PM
Hey there,
I am trying to make a new portfolio site for myself and I have a preloader.swf that loads the main.swf. The structure of the main flash looks like this:
Main.fla
Main.as

/ui
Nav.as
Body.as
/utils
fullscreenScrollBar.as
BitmapLoader.as

In the Main.as, I have this in the constructor:
// setup stage
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, onResize);

When I play the preloader.swf, however, some error occurs and fails to load. Without the stage properties, the whole thing works fine. How can I add stage properties while using an external swf for preloader?

My preloader is just one fla with actionscript on timeline.
just a simple loader:


var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("Main.swf");
mLoader.contentLoaderInfo.addEventListener(Event.C OMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);

function onCompleteHandler(loadEvent:Event) {
removeChild(mc_preLoader);
this.addChild(loadEvent.currentTarget.content);
}

function onProgressHandler(mProgress:ProgressEvent) {
var percent:Number = Math.round(mProgress.bytesLoaded*100/mProgress.bytesTotal);
mc_preLoader.gotoAndPlay(percent);
mc_preLoader.txt_number.text = percent;
}

a tadster
August 15th, 2009, 04:54 PM
Put all stage related commands in the preloader.
For the resize event just use addEventListener(..) without stage. .

myoreo
August 15th, 2009, 05:22 PM
hey thanks! that worked. I just put the stage align properties in the preloader and the resize function (minus stage) in the Main and now it works. :yoda: