I have a action script from a decompile flash like this
public function getResourceAsByteArray(resID:int):flash.utils.ByteArray
{
var tempByteArray:*=null;
var fName:*=this.clazzName;
var resDataDup:*=new clazzByteArray() as flash.utils.ByteArray;
var resPos:*=this.post;
var resLength:*=1024;
var resultByteArray:*=new flash.utils.ByteArray();
resDataDup.position = resPos;
resDataDup.readBytes(resultByteArray, 0, resLength);
return resultByteArray;
}
public class clazzByteArray extends mx.core.ByteArrayAsset
{
public function clazzByteArray()
{
super();
return;
}
}
I’m not a action script programmer, but I try to understand this function.
resDataDup is a local object from a class that extends ByteArray, and I think with this initialize way resDataDup will always empty, so the next readBytes call always fail. Is there a chance it can work in other way? (some one can put data to resDataDup before readBytes is called), or the decompiler did not generate it correct.
You’re absolutely correct. This code will not work. I suspect that what your decompiler is not telling you is that ByteArrayAssets are primarily for embedded assets in Flex. This means that
clazzByteArrayis actually referencing some thing which used to be embedded. But, that does not help here.