Jump to content
GreenSock

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

loading external swfs from a simple navigation menu

Recommended Posts

Hi everyone,

 

I had my school project setup with the regular flash swf loaders, but some of my files are setup in such a way where suppose I am loading about.swf in main.swf then about.swf is also loading abc.swf, so sometimes while loading it doesn't go to alpha = 1 and just shows up on half opacity. Anyway in a desperate time like this I am turning once again to greensock.

 

This is what I have setup right now.

//Loader files to load SWF files into the main file
var SWFLoader:Loader = new Loader();
var preLoader:preLoad_mc = new preLoad_mc();

//using our loader to load an external file
function loadFile(filePath:String)
{
currentPage = filePath;
addChild(preLoader);
preLoader.x = 400;
preLoader.y = 350;
SWFLoader.load(new URLRequest(filePath));

SWFLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progInfo);
SWFLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,finishLoad);

}

function progInfo(event:ProgressEvent):void
{
var percent:Number = Math.round(event.bytesLoaded/event.bytesTotal * 100);
preLoader.load_text.text = percent + "%";
preLoader.prog_bar.scaleX = percent/100;
}

function finishLoad(event:Event):void
{
SWFLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,progInfo);
SWFLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,finishLoad);
removeChild(preLoader);
load_area_mc.addChild(SWFLoader);
var swfTween = new Tween(load_area_mc,"alpha",None.easeOut,0,1,0.25,true);

}

/* ----------- Menu ---------------- */

about_btn.addEventListener(MouseEvent.CLICK, goAbout);

function goAbout(e:MouseEvent):void{
loadFile("about.swf");
}

 

What is the easiest way to get this working in using loadermax? and in the about.fla I will use a similar code to load the abc.swf?

 

Also, does loadermax have it's own preloader animation? that will work too, cos I am not that worried about how the animation shows as long as it gives a percentage.

 

I tried to understand the tutorials, but not sure if it will work the same way for swfs instead of images, so decided to ask here.

 

Thank you so much.

Link to comment
Share on other sites

you should familiarize your self with the basic GreenSock SWFLoader:

http://www.greensock.com/as/docs/tween/ ... oader.html

 

It is very easy to load a single swf and the documentation is very detailed.

 

As for loading a swf that loads a swf and tracking the overall progress read this:

viewtopic.php?f=6&t=5099

 

It may also be beneficial to read the documentation on LoaderMax.

 

Once you have something sort of working, people can direct you on how to get around problems.

 

In basic terms you create a LoaderMax that contains a SWFLoader that loads about.swf.

about.swf will contain its own SWFLoader that has a requireWithRoot property:

 

requireWithRoot : DisplayObject - LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this SWFLoader as part of its parent SWFLoader's progress, you must set the requireWithRoot property to your swf's root. For example, var loader:SWFLoader = new SWFLoader("subload.swf", {name:"subloadSWF", requireWithRoot:this.root});

 

---

 

There is no built-in progress animation.

Link to comment
Share on other sites

Super! Thanks once again Carl.

 

I'll have a look at the documentation and see if I can wrap my head around it :)

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.
×