# Simple Preloader PLEASE HELP :(

**URL:** <https://forum.kirupa.com/t/simple-preloader-please-help/320849>\
**Category:** flash\
**Created:** [April 3, 2011, 4:42pm UTC](https://forum.kirupa.com/t/simple-preloader-please-help/320849 "2011-04-03T16:42:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisW182](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@ChrisW182](https://forum.kirupa.com/u/ChrisW182)\
**Post date:** [April 3, 2011, 4:42pm UTC](https://forum.kirupa.com/t/simple-preloader-please-help/320849/1 "2011-04-03T16:42:27Z")

</div>

Hey guys i have a project (see screenshot for layout of timeline) that has three main pages, ‘home’, ‘gallery’,‘contact’. On the home page an external .swf (random animation) is loaded in, what i want is a preloader for that animation being loaded in. I thought i had it but i was mistaken.

Here is my AS code for frame 1 (which is the home page), apologies if it doesnt follow normal structure, i am brand new to flash.

```auto
import fl.controls.ProgressBar;
import flash.events.Event;
swfOnStage = true;
currentPage = "home";
/*
You must keep the variables and functions you can write 
additional ones but you must not start from scratch.
on scene home - delete the layer with named animation and create the animation this size
*/
 

//loading the animation
var swfRequest:URLRequest = new URLRequest("assignmentfinal.swf");
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded, false, 0, true);
swfLoader.load(swfRequest);

function swfLoaded(event:Event):void
{
swfLoader.x=40;
swfLoader.y=150;
addChild(swfLoader);
}

// used to navigate to the home page
homeBT.addEventListener(MouseEvent.CLICK, homeDisplay);
function homeDisplay(event:Event):void
{
 if ((swfOnStage==true)&&(currentPage != "home"))
 {
  swfOnStage= false;
  removeChild(swfLoader);
 }
 if (galOnStage==true)
 { galOnStage= false;
  removeChild(galleryhold);
 }
 gotoAndStop("home");
}

// used to navigate to the gallery page
galleryBT.addEventListener(MouseEvent.CLICK, galleryDisplay);
function galleryDisplay(event:Event):void
{
 if (swfOnStage==true)
 {
  swfOnStage= false;
  removeChild(swfLoader);
 }
 if ((galOnStage==true)&&(currentPage != "gallery"))
 { 
  galOnStage= false;
  removeChild(galleryhold);
 }
 gotoAndStop("gallery");
}

// used to navigate to the contact page
contactBT.addEventListener(MouseEvent.CLICK, contactDisplay);
function contactDisplay(event:Event):void
{
 if (swfOnStage==true)
 {
  swfOnStage= false;
  removeChild(swfLoader);
 }
 if (galOnStage==true)
 {
  galOnStage= false;
  removeChild(galleryhold);
 }
 gotoAndStop("contact");
}
stop(); 

```

If anyone could help me with this i would really appreciate it.

Chris W
