Is this action script correct
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 clazzByteArray
is actually referencing some thing which used to be embedded. But, that does not help here.
The decompiler is wrong. As @cwallenpoole said, that ByteArray was most likely an asset embedded with mxmlc (Flex SDK Compiler) rather than the Flash IDE, which uses a different mechanism.
There are however decompilers, that can handle Flex projects, such as the Sothink Decompiler. If you're already using it, maybe you'll have more luck if you tell it to decompile the SWF to a Flex project rather than an .fla.
精彩评论