package { import flash.display.Sprite; import flash.events.Event; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import flash.media.Sound; import flash.net.URLRequest; import flash.net.URLStream; import flash.utils.ByteArray; public class FileWriteTest extends Sprite { private var fileData:ByteArray = new ByteArray; private var sound:Sound; public function FileWriteTest() { super(); this.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage); } private function onAddedToStage(e:Event):void{ var urlstream:URLStream = new URLStream; urlstream.load(new URLRequest("http://www.도메인.com/사운드.mp3")); urlstream.addEventListener(Event.COMPLETE, this.onLoadStream); } private function onLoadStream(e:Event):void{ var urlStream:URLStream = e.target as URLStream; urlStream.readBytes(fileData, 0, urlStream.bytesAvailable); var file:File = File.documentsDirectory.resolvePath("file://폴더/사운드.mp3"); var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.WRITE); fileStream.writeBytes(fileData, 0, fileData.length); fileStream.close(); var sound:Sound = new Sound; sound.load(new URLRequest(file.url)); sound.play(); } } }개고생했다.-_-)b 공유하기 게시글 관리 개발자 향기 저작자표시