Rel*_*lla 2 air flash actionscript bytearray file
我读有限(小 - 15 - 500 MB文件).我需要能够将所有文件字节放入一个单独的bytearray中.所以我有一个功能:
[Bindable]
public var ba:ByteArray = new ByteArray;
//.... code ....//
protected function fileOpenSelected(event:Event):void
{
currentFile = event.target as File;
stream = new FileStream();
stream.openAsync(currentFile, FileMode.READ);
stream.readBytes(ba);
stream.close();
MyFunction(ba);
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用=( - 给我错误:错误#2030:遇到文件结束.
如何从流中获取完整的bytearray以将其用作普通的bytearray?
在查看文档一段时间之后,我终于想出了这个.呼!
就我而言,我不得不将wav文件读作我正在使用的类的bytesArray,因此我可以在公共范围内按需使用它.
var file:File = File.applicationDirectory.resolvePath("blip.wav");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var bytes:ByteArray = new ByteArray
fileStream.readBytes(bytes);
fileStream.close();
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.我测试了它并确认它有效.