Jump to content


DataLoader load *.wav

Recommended Posts

Hi there,


i try to load audio data *.wav with the DataLoader in Flex AS3 and got an conversion error.


I used parts of the example from the DataLoader.


import flash.utils.ByteArray;


var loaderMax:LoaderMax = new LoaderMax({onComplete:loaderComplete});

loaderMax.append(new DataLoader("assets/test.wav", {name:"myBinary", format:"binary"}));



function loaderComplete(event:LoaderEvent):void


var binary:ByteArray = LoaderMax.getContent("myBinary");



The Result is:

Error #1034: Type Coercion failed: cannot convert com.greensock.loading::DataLoader@a74c821 to flash.utils.ByteArray.


I think DataLoader returns a ByteArray? Why is there a conversion needed and ends with error?


Thanks for help.


Link to comment
Share on other sites

That almost sounds like a security issue - are you subloading across domains without a valid crossdomain.xml file in place? Or are you maybe loading cross SecurityDomains, like if your parent is running locally but the .wave file is remote (or visa-versa)?


If you're still having trouble, please post a set of simplified files that clearly demonstrate the issue so that we can publish on our end and see exactly what's happening.

Link to comment
Share on other sites

No, i think the Problem is different.

I do the same procedure with Images, like jpg gif bmp an the ImageLoader and it works.



loaderMax.append(new ImageLoader(get_wf_files[j].nativePath, {name:get_wf_files[j].name}));


The App where i tested the loader is AS 3 and AIR inside Flex 4.6 and all is local on Desktop PC.


The Images are loading from a directory : get_wf_files = work_folder.getDirectoryListing();

The different how i get the files are: (rawContent)

bitmap = LoaderMax.getLoader(fileName[counter]).rawContent;


All is fine.


So i changed the Loader to DataLoader, add the format:"binary" and try to do the same with *.wav and without .rawContent.


I try it with 8bit PCM, 16bit PCM 44100.

Link to comment
Share on other sites

Would you mind uploading a very simple example set of files (including FLA) that demonstrates this error that you're getting so that we can publish on our end and see what's going on?

Link to comment
Share on other sites

You were using LoaderMax.getLoader() instead of LoaderMax.getContent().

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.