Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
forrestmaready

Hide Preloader after External SWF has loaded

Recommended Posts

I have a generic preloader swf with progress bar. After my external swf has loaded, I can still see my preloader swf. It's not completely on the top layer of the display list, but it's pretty easily visible.

 

Is there an easy way to completely hide the Preloader Swf once it's done loading the external swf?

 

Many thanks-

 

 var loader:SWFLoader;

 public function PreLoader() {
  loader = new SWFLoader("game.swf", {name:"mainSWF", container:this, x:50, y:100, onprogress:progressHandler, estimatedBytes:9500});
  loader.load();
 }

 function progressHandler(event:LoaderEvent):void {
  progBar.scaleX = event.target.progress;
 }

 function completeHandler(event:LoaderEvent):void {
  addChild(event.target.content);
 }

Link to comment
Share on other sites

yes, in your completeHandler just do

 

progBar.visible = false
//or for a nice fade out:
TweenLite.to(progBar, .5, {alpha:0});

 

I noticed that your onComplete isn't registered in your SWFLoader constructor. So you will need to further do this:

 

loader = new SWFLoader("game.swf", {name:"mainSWF", container:this, x:50, y:100, onprogress:progressHandler, onComplete:onCompleteHandler, estimatedBytes:9500});

 

also, since you are specifying a container in your SWFLoader you don't need to do

addChild(event.target.content);

Link to comment
Share on other sites

Thank you- so if my PreLoader has a bunch of items in it, I have to manually remove them all one at a time?

Link to comment
Share on other sites

You're welcome.

 

if my PreLoader has a bunch of items in it, I have to manually remove them all one at a time?

 

No, just remove the parent that contains all the little parts.

Link to comment
Share on other sites

Thanks- I had all the preloader items floating around on the stage. I suppose the correct form is to put them all in a container so they can be removed easily. That seems to work fine.

 

Many thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×