Jump to content
Search Community

Invalid sound getLoader

NIKESLB test
Moderator Tag

Recommended Posts

Hi,

I found greensock today and its very great. I tried the Loadermax but I got a problem.
I have two class: Main.as and Loader.as.

 

Loader.as:

var urls:Array = ["graphics/home/card.png", "sounds/test.mp3"];
LoaderMax.activate([ImageLoader,MP3Loader]);
var queue:LoaderMax = LoaderMax.parse(urls, {onProgress: progressHandler, onComplete: completeHandler}, {autoPlay:false});
queue.prependURLs("media/"); 
queue.load();
...

Main.as

//this function call and create a new Loader()
beginLoad();	

var img:ImageLoader = LoaderMax.getLoader("media/graphics/home/card.png");
getStage.addChild(img.content);
			
var s:MP3Loader = LoaderMax.getLoader("media/sounds/test.mp3");
s.playSound();

The image display well but the sound is giving an error:
ArgumentError: Error #2068: Invalid sound.
 at flash.media::Sound/play()
 

If i put this codes in the Loader.as it works, but not in the Main.as. There is any solution to solve that please?

 

*One more thing, there is a way to know wich files was loaded(or are inside) by LoaderMax?

Link to comment
Share on other sites

Hi and welcome to the forums.

 

Are you sure the sound is loaded before you are trying to play it?

Have you tried waiting for the LoaderMax's onComplete to fire?

 

 

Very difficult to analyze what is happening from 2 snippets of code from 2 files.

Feel free to upload a simplified set of zipped files that only contains enough code and assets to reproduce the issue.

 

As for your second question, not exactly sure what you need, but LoaderMax has getChildren() and getChildrenByStatus() methods that should help you. 

http://api.greensock.com/as/com/greensock/loading/LoaderMax.html

 

getChildren() gives you  and array of all loaders which you can then loop through and check the status of them to see if they are loaded

 

getChildrenByStatus() gives you an array of loaders based on their status, so you could easily get only loaders that have loaded.

 

Let us know if you need more help and or have any more questions.

Again, if you still have a sound issue, it looks like it would help if we coudl test the files.

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