Jump to content
Search Community

How to remove all loaded swf files, except one, from Xml file?

Sakar test
Moderator Tag

Recommended Posts

Hello GreenSock!

 

Congrats for your Amazing job.

I’m really a first timer with AS3, Greensock and have no skills with programming.

 

I just made a huge personal flash website and I was stacked with the LoaderMax and XMLLoader.

Never made it work. (Need a lot of studying)

 

But this tutorial helps me like a charm: (thanks to Carl)

http://www.snorkl.tv...-the-xmlloader/

 

 

From the XML file, I load with succeed, the Main swf plus 200 swf files.

Main swf loaded at x:0 y:0 and

all other swf files at x:3000 and y:3000

Just far away from the stage. Everything load and work ok, but

Loading 200 files on the stage makes fps to 2-5/sec

 

How can I remove all loaded swf from the stage, except from the Main swf ???

 

I use the same actionscript and xml from Carl's tutorial.!

 

Thanks

Sakar

Link to comment
Share on other sites

interesting situation.

what you can do is loop through all the loaders from your xml and unload() all of them except main.swf.

 

I altered my original tutorial files to include a button that unloads all the images except for the one with name "crab" (as specified in the xml).

 

here is the code:

 

unload_btn.addEventListener(MouseEvent.CLICK, unloadHandler);
function unloadHandler(e:MouseEvent):void{

var nameOfAssetToKeep:String = "crab";

var assetsArray:Array = queue.getChildren();
var numOfAssets:int = assetsArray.length;

trace("numOfAssets = " + numOfAssets);

for(var i:int = 0; i < numOfAssets; i++){
 if(assetsArray[i].name != nameOfAssetToKeep){
  assetsArray[i].unload();
  }
 }
}

 

flash cs4 fla attached (save it into the same folder as the other tutorial flas)

loadMultipleImages_XMLLoader_unloadCustom.fla.zip

Link to comment
Share on other sites

Thanks for your very fast reply Carl !

 

This script works and it’s very nice.

Your tutorial is the best way I can find for now.

But loading a big website, I see it’s not the right way to load everything at start.

 

I was start building my website before I meet Greensock LoaderMax.

When I need to load some swf, I use URLRequest and load swf inside a Movieclip.

200 Different URLRequests inside 200 different Mcs.

 

After that I realize that the loading process loads everything on “background” is boring for visitors to wait.

Every URLRequest loads too slow because all other URLRequests is been loaded at the same time.

 

So, your way and my way, think is not the perfect choice for my website.

What do you think?

 

Is there any way to force start and complete loading the particular swf only when request?

I don’t know what to do about it. And have no LoaderMax skills

 

All I know is ,all that 200 swf files needs a better download process.

Total size is 30MB and its too much heavy, loading all, at first page.

I feel so bad about that.

 

Hope to find a better solution.

 

Thanks

Sakar

Link to comment
Share on other sites

Yeah, loading 200 swfs up-front is not a great approach.

You can load any asset based on the user's selection as long as you know the name or url of the SWFLoader.

 

after your xml has loaded you can do

 

LoaderMax.getLoader("someSwf").load();

Link to comment
Share on other sites

I didn't get that.

What do you mean:

"...as long as you know the name or url of the SWFLoader"

 

how can I fire that from the Main swf.?

Main.swf = the first loaded swf from xml and had all the buttons inside.

 

Thanks

Sakar

Link to comment
Share on other sites

the name and url of each SWFLoader is all in the xml. once the xml loads you can read all of that info and tell different buttons to be in charge of loading specific SWFLoaders.

 

I don't think I really understand everything you have going in your project or how the user is supposed to interact with or navigate to all 200 swfs;(

Link to comment
Share on other sites

Reorient the swfs lines inside the xml and cut some unnecessary from it, is a bit better.

 

Let's say we have an (almost) empty swf, used "as a loader" for xml.

From the xml, we start loading first, the Main.swf (All buttons - and empty pages there)

and then, loading all the others swfs to be placed inside the empty pages.

 

This code didn't work inside the Main.swf

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.Sprite;
import flash.display.MovieClip;

LoaderMax.activate([imageLoader, SWFLoader]);

tst.buttonMode = true;
tst.addEventListener(MouseEvent.CLICK, tstClick);

function tstClick(e:MouseEvent):void{
LoaderMax.getLoader("mous").load();
}

 

Something is missing. (maybe the xml path)

 

Before all of that, I was tried to put the code from your tutorial to the Main.swf

but I get a lot of errors. That's why I use the empty swf as a loader for everything else.

 

Now, URLRequests as I said at previous message, are still remain inside the Main.swf

I'm afraid that I make a double load of my files.

 

Thanks again.

Sakar

Link to comment
Share on other sites

what do you mean by it didn't work?

did you get errors?

where are you defining the container that "mous" should get loaded into?

 

I'm wondering if perhaps it loaded, but just isn't being placed on the stage.

 

if you want to edit and package your files so that only 1 or 2 swfs needs to load from main.swf I can take a look at it.

Link to comment
Share on other sites

I didn't defining the container.

I don't know how to do that.

 

If it's loaded from xml file, why its not being placed on the stage.?

 

By the way

I don't have the time now to experiment more with that.

 

I'll start a new post for any of my new questions

 

You really help me a lot. I appreciate that :mrgreen:

 

Thanks

Sakar

Link to comment
Share on other sites

If it's loaded from xml file, why its not being placed on the stage.?

 

just like in my tutorial sample you need to use addChild() in your completeHandler.

when defining your SWFLoader in the actionscript you can use the container property, but that doesn't work when the SWFLoader is defined in the xml.

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.
×
×
  • Create New...