import flash.filesystem.*;
/// Change the line below to point to your mp3 online
var urlString:String = "http://edvizenor.com/upload/php/files/trust.mp3";
var urlReq:URLRequest = new URLRequest(urlString);
var urlStream:URLStream = new URLStream();
var fileData:ByteArray = new ByteArray();
urlStream.addEventListener(Event.COMPLETE, loaded);
urlStream.load(urlReq);
function loaded(event:Event):void
{
urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
writeAirFile();
}
function writeAirFile():void
{
// Change the folder path to whatever you want plus name your mp3
// If the folder or folders does not exist it will create it.
以下是我需要帮助的内容:
var file:File = File.userDirectory.resolvePath("Yahoo.mp3");// WORKS
var file:File = File.applicationDirectory.resolvePath("Yahoo.mp3"); // NO WORK
我需要得到这第二行以保存到它存储的目录。任何想法我做错了什么?
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(fileData, 0, fileData.length);
fileStream.close();
trace("The file is written.");
}