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
この2行目を保存先のディレクトリに保存する必要があります。何が間違っているのでしょうか?
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(fileData, 0, fileData.length);
fileStream.close();
trace("The file is written.");
}