Skip to main content
Known Participant
June 26, 2010
Question

Preloader/Full Screen Issue

  • June 26, 2010
  • 1 reply
  • 1016 views

This is the page that Im working on: www.houseofopama.com/temp.html . I am loading opama.swf into preloader.swf and using a code so that I can have a full screen background image. However, my background image covers my preloader while its loading. & I would like my loaded movie to be centered and scaled. Can someone help me with this???

Here's my code:

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("opama.swf"));
stage.align = StageAlign.BOTTOM;

function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(l);
}
var loader:Loader = new Loader();
var mc:MovieClip = new MovieClip();

stage.scaleMode = StageScaleMode.NO_SCALE
stage.align = StageAlign.TOP_LEFT;

loader.load(new URLRequest("http://www.houseofopama.com/jpeg-tile.jpg"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, c);

function c(event:Event):void {
   mc.addChild(loader);
   this.addChild(mc);
   mc.width = stage.stageWidth
   mc.height = stage.stageHeight
   stage.addEventListener(Event.RESIZE, r);
}

function r(event:Event):void {
   mc.width = stage.stageWidth
   mc.height = stage.stageHeight
   mc.x = 0;
   mc.y = 0;
}

***Kglad, I know u probably know what to do, if u see this***

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 26, 2010

1.  use addChild(percent) whenever you want to move percent to the top of its parent's displaylist.

2.  to center a loaded image/swf when loading is complete:

loader.x=(stage.stageWidth-loader.width)/2;

loader.y=(stage.stageHeight-loader.height)/2;

Known Participant
June 26, 2010

Hey Kglad, I knew you'd have a solution! Where would i place that in my code????

kglad
Community Expert
Community Expert
June 26, 2010

the first you place wherever and whenever you want to move your preloader.  the second you place in the loader's complete listener function.