# as3 preloader help

**URL:** <https://forum.kirupa.com/t/as3-preloader-help/324997>\
**Category:** flash\
**Created:** [September 20, 2011, 5:34pm UTC](https://forum.kirupa.com/t/as3-preloader-help/324997 "2011-09-20T17:34:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fonzio](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@fonzio](https://forum.kirupa.com/u/fonzio)\
**Post date:** [September 20, 2011, 5:34pm UTC](https://forum.kirupa.com/t/as3-preloader-help/324997/1 "2011-09-20T17:34:55Z")

</div>

hi all

i have a preloader which loads everything up to the main page

next i wish to start preloading the games also, but not into content\_mc (which holds the main as it takes a while to preload as it is, so i hide it and want to place another MC, between content\_mc and the togglebutton, into which i can start loading the games, unsure how to go about this, here is the code which loads each page in turn into the content mc movieclip

any help much appreciated

```auto
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
var myMovieClip:MovieClip = new toggleButton();
var games_mc:MovieClip = new MovieClip();
var content_mc:MovieClip = new MovieClip();
myMovieClip.x = 780.0;
myMovieClip.y =30.0;
addChild(content_mc);
addChild(games_mc);
addChild(myMovieClip);
var loadedSWF:Loader
var progressPercent:Number;
 function startLoad(SWFName:String):void {
    loadedSWF = new Loader();
 loadedSWF.contentLoaderInfo.addEventListener(Event.COMPLETE, gameLoaded);
 loadedSWF.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    loadedSWF.load(new URLRequest(SWFName+".swf"));   
    
}
//track progress
function onProgressHandler(loadingProgress:ProgressEvent){
 var percent:Number = loadingProgress.bytesLoaded/loadingProgress.bytesTotal;
 
 progressPercent = Math.round((percent*100));
 preload_mc.gotoAndStop(progressPercent);
 preload_mc.myloadtext_txt.text=(progressPercent + " %")
  preload_mc.myloadbar_mc.scaleX = percent;
  preload_mc.mc_mask.height=(progressPercent * 3);
 preload_mc.ofBytes_txt.text = loadingProgress.bytesLoaded + " bytes";
 preload_mc.totalbytes_txt.text = loadingProgress.bytesTotal + " total bytes";
}
   
function gameLoaded(e:Event):void{
 
 removeChild(preload_mc);
 content_mc.addChild(loadedSWF);
 
 loadedSWF.contentLoaderInfo.removeEventListener(Event.COMPLETE, gameLoaded);
 loadedSWF.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgressHandler);
}
function nextSWF(whichSWFName, removeSWF){
    if(whichSWFName == "startPages"){
 content_mc.removeChild(removeSWF.parent);
   addChild(preload_mc);
  startLoad("wholesite");
 }
  if(whichSWFName == "wholesite"){
        addChild(preload_mc);
  startLoad("explan0");
  }
 
}

```

hope you can help

thanks in advance  
fonzio
