Jump to content
Search Community

MP3Loader: content is null

JBrubaker test
Moderator Tag

Recommended Posts

I'm trying to use LoaderMax to load mp3 files. All of the other file types (SWF, .txt, etc) I'm loading in the same application work. However, the "content" property of the MP3Loader is always null. I've checked the status (2: COMPLETE), the progress (1), and the scriptAccessDenied (false). I've double-checked the URL, and I'm tracing any errors (none show up). Any help would be appreciated.

 

In the following code, asset_id is the "name" passed in to the MP3Loader object in its constructor. Also, I'm not casting as MP3Loader because I need to return different things based on the loader type.

 

var obj:LoaderCore = LoaderMax.getLoader(asset_id);
.
.
.
return obj.content;

Link to comment
Share on other sites

Sounds like maybe you're passing the wrong name? Not sure - I just tested MP3Loader and it worked great for me, returning a Sound object for the "content". If you're still having trouble, please post a sample FLA and MP3 that demonstrates the issue.

Link to comment
Share on other sites

Sounds like maybe you're passing the wrong name?

 

I assume that if I pass the wrong name, that my obj:LoaderCore would be null. However, as I mentioned, I can access the status and progress of this object. This would indicate to me that the name is not the issue. Can you think of any reason an MP3Loader object would have the status be 2 (Complete), but have the content be null?

 

I'll post a sample a little later if I get time.

Link to comment
Share on other sites

Can you think of any reason an MP3Loader object would have the status be 2 (Complete), but have the content be null?

 

Absolutely not - if you look in MP3Loader's source code, you'll see the the content is set IMMEDIATELY when you create the instance so it shouldn't be null...ever.

Link to comment
Share on other sites

Okay, I might know what's happening. I'm creating a LoaderMax object, appending a bunch of individual loaders (including some MP3Loaders), then calling

_queue = new LoaderMax( { name:_identifier, onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler, onChildComplete: childComplete } );
_queue.prependURLs(path_prefix, true);

 

Here's prependURLs:

public function prependURLs(prependText:String, includeNested:Boolean=false):void {
var loaders:Array = getChildren(includeNested, true);
var i:int = loaders.length;
while (--i > -1) {
	LoaderItem(_loaders[i]).url = prependText + LoaderItem(_loaders[i]).url;
}
}

 

Here's LoaderItem.url:

public function set url(value:String):void {
if (_url != value) {
	_url = _request.url = value;
	var isLoading:Boolean = Boolean(_status == LoaderStatus.LOADING);
	_dump(0, LoaderStatus.READY, true);
	if (isLoading) {
		_load();
	}
}
}

 

And here's MP3Loader.dump:

override protected function _dump(scrubLevel:int=0, newStatus:int=0, suppressEvents:Boolean=false):void {
_initSound();
super._dump(scrubLevel, newStatus);
}

 

 

First, _initSound() sets "_sound = _content = new Sound();"

Then, _dump() (in LoaderCore) sets "_content = null;"

 

So, when the MP3Loader is loaded, _sound is not null, but _content is null, because the reference has been destroyed in dump.

 

I've attached a file demonstrating the error.

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