Jump to content
Search Community

empty() method

Fernando test
Moderator Tag

Recommended Posts

Yes.. but depends on what do you understand by immediately.. :-)

I want to empty all the loaded data, but it takes a while (maybe less than a second) but enough time to take into account.

But if there's no such event, I could make things differently to bypass the problem.

 

Thank you.

Link to comment
Share on other sites

One more question...

 

If I call the empty method and right afterwards add new loaders to the same loaderMax, will they load correctly? or will they be emptied in the process.. because the new loaders will be added at the end... and if the empty process is not finished yet...

 

Regards

Link to comment
Share on other sites

No no, when you empty() a LoaderMax, you don't need to wait while other code runs asynchronously with the rest of your code. As soon as empty() is executed, your LoaderMax is empty. That's it. It doesn't keep trying to empty things after that point. You don't need to worry that inserting/appending new loaders after an empty() call will somehow cause the new ones to disappear.

 

So there's no need to wait for an event to be dispatched either before having confidence that the function actually completed running.

 

Garbage collection in the Flash Player is a different issue, though - technically memory may not be freed up immediately when empty() is called but that's totally normal. That has nothing to do with loaders remaining inside the LoaderMax or anything like that.

 

Does that answer your question?

Link to comment
Share on other sites

Yes.. but no.. :-)

 

Here is my scenario..

 

I load some images into containers that are child on mainContainer (let's say), but at certain point the user choses another gallery, so loaded images have to be unloaded, so new ones could load. What I did before was to set alpha of mainContainer to 0, call:

 

loaderMaxInstance.empty(true, true);

 

and then set the alpha back to 1 before start loading new images, so they'd display correctly.

Well, that didn't work very well, because when alpha was set to one, old images were still visible for a short period of time before they were unloaded.. but still, maybe that was only flash garbage collection...

 

What I do now is after setting alpha to 0, remove all children with something like:

while(mainContainer.numChildren) { mainContainer.removeChildAt(0); }

 

so when I set alpha back to one, nothing is there to see, even is garbage collection still didn't do it's work.

Link to comment
Share on other sites

Well, that didn't work very well, because when alpha was set to one, old images were still visible for a short period of time before they were unloaded.. but still, maybe that was only flash garbage collection...

Hmmm...could you post an FLA that demonstrates that behavior? It sounds to me like there's something else going on in your code that would cause the issue because when dispose(true) is called on an ImageLoader (and it would be when you empty(true, true) its LoaderMax), it IMMEDIATELY removes the ContentDisplay from the display list. I suspect that maybe you have an old version of the classes. What version are you using? I'd recommend getting the latest and greatest: http://www.LoaderMax.com and make sure you COMPLETELY replace all the stuff in the com/greensock/loading/ directory and subdirectories with the new files.

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