Copy link to clipboard
Copied
How are you supposed to access the data in a ByteArray? ByteArray.readBytes reads into another byte array which perpetuates the problem. I want to return the data so that I can manipulate it. What am I missing?
var data = new ByteArray();
var file = new File(path);
var pos = 0;
var bytes = 500 * 1024; // bytes
if( !file.exists ) {
trace(path + ' does not exist');
return;
}
/*
| Opens an FLV file in binary mode
*/
if( !file.open('binary', 'read') ) {
trace('Cannot open file');
return;
}
if( file.length < bytes ) {
bytes = file.length;
}
/*
| Neither valueOf or toString provide the data I want.
| Both return "FLV" as a value not the data.
*/
file.readBytes(data, pos, bytes);
trace(data.valueOf()); // DOES NOT WORK
trace(data.toString()); // DOES NOT WORK
Copy link to clipboard
Copied
Thread little old, but I guess that a serialization of bytes was needed here.