in my application , I want to download a mp3 file for remote server ,then play it . now I'd like to save the sound to local , for play it from the file later , just like a cache . I've tried to extract the raw data to a file when the sound object load complete ,
sound.addEventListener(air.Event.COMPLETE, function(event){
var cacheFileStream = new air.FileStream();
var file = cacheDirectory.resolvePath("testfile1");
cacheFileStream.openAsync(file, air.FileMode.WRITE);
cacheFileStream.position = 0;
var dataBuffer = new air.ByteArray();
var targetSound = event.target;
targetSound.extract(dataBuffer,targetSound.bytesLoaded,0);
log(dataBuffer.length);
cacheFileStream.writeBytes(dataBuffer, 0, dataBuffer.length);
cacheFileStream.close();
air.Introspector.Console.log('load complete');
});
but how to play it?