Jump to content
Search Community

Why would you override dispose(); ?

JFP test
Moderator Tag

Recommended Posts

Hi there,

 

there's a weird function I don't quite understand the purpose of in a script I hired somebody to write. 

Im hunting for a bug that causes the application Im working on to crash sometimes. I'm wondering if it's the following:

 

override public function dispose():void
		{
			trace("dispose" + this.name);
			thumbholder.removeEventListener(MouseEvent.CLICK, onThumbClick);
			infoWindow.closer.removeEventListener(MouseEvent.CLICK, onCloseClick);
			langChooser.removeEventListener(Event.CHANGE, onLangChange);
		}

Would the script above have any influence on thie following:

 

private function closeInfo():void
		{
			
			if (loader != null) {
				loader.dispose(true);
				loader = null;
			}
			TweenMax.to(infoWindow, 1, {autoAlpha:0});
			infoWindow.whiteout.gotoAndStop(1);
			langChooser.visible = false;
		}

Because there's also a bunch of images and mp4's that get loaded - would the overriding of the dispose function leave those videos and images in the memory, bloating it until the application crashes due to overfilling the memory? I mean do just the eventListeners get removed this way or does overriding dispose() this way still permit the command to get rid of anything else in the loader?

Any help would be much appreciated. 

edit: Also, nothing gets traced out in the debugger so    trace("dispose" + this.name);     seems odd to me as well.. 
 

Link to comment
Share on other sites

It's very difficult to troubleshoot blind, but I can say that the dispose() method in LoaderMax will only clean up LoaderMax's own listeners and other internal things to make it eligible for garbage collection. There's no way it can know what other gc-blocking things you may have done outside the class, so you need to make sure that you remove any event listeners of your own, close any NetStreams, etc. (well, unless the NetStream is originating from LoaderMax's own VideoLoader - it will clean up those in dispose()). 

 

I'm also a little unclear about what you mean by "override dispose()" because if you truly are extending one of the LoaderMax classes and overriding the dispose() function, that's fine but you need to make sure you're calling super.dispose(), otherwise you're skipping over all of the important stuff that LoaderMax's own internal systems do. 

 

I hope that helps!

  • Like 1
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...