Archive for December, 2007

Wednesday, December 12th, 2007

Playing MP3 data using the Flash sound “hack”

A recurrent question that I see after writing the article “How to make actionscript 3 play generated pcm wave data” is how would one do this with MP3 data.

I spent a while hacking around to see if it could be done, and came up with this.

Not much time to write anything about this, but I thought that I should just post up the code. It requires an mp3 called “sample.mp3″ in the “media” folder in order to work. There should be a certain amount of resilience to errors in the MPEG stream.

We’re not opening up comments at the moment, so please post back to the original pcm wave data article if you have any comments.

Sunday, December 9th, 2007

Test all files in a folder

Making use of the FLFile api in Javascript for Flash (JSFL) can be quite handy when dealing with large numbers of files. Here’s a scrap that I have been using to test a folder full of files:


var srcFolder="file:///path/to/a/directory";
var files=FLfile.listFolder( srcFolder , "files" );
for(var i=0;i<files.length;++i)
{
var fileName=files[i];
var fileSuffix=fileName.substr(-4);
if(fileSuffix.toLowerCase()==”.fla”)
{
fl.trace(”testing : “+fileName);
test(srcFolder+”/”+fileName);
}
}
function test(fileName)
{
var doc=fl.openDocument(fileName);
doc.testMovie();
doc.close();
}

Seing as I feel like I’ve written this piece of code about 20 different times, here seems like a good place to drop it for preservation.