Extending ByteArray
Hello,
Short version : How can I make the code snippet at the bottom of this message
compile and run without a VerificationError ?
Long version
For some Flash 10 project of mine I'm trying to develop a "lockable" ByteArray
class, because I need to pass sensitive binary data to third-party libraries
implementaing my interfaces, and I don't want them to be able to change it.
For that purpose I made a class that extends ByteArray and overrides all
methods that could change the array contents (write*, clear, compress,
decompress, inflate, deflate). I attached a shortened version of it to this
message.
So the code compiles all fine, but the problem comes at run time :
[Q]VerifyError: Error #1053: Illegal override of clear in
org.sprods.security.LockableByteArray.[/Q]
For the sake of testing I commented my override, and I get this at run time
when I try to call clear() :
[Q]ReferenceError: Error #1069: Property clear not found on
org.sprods.security.LockableByteArray and there is no default value.[/Q]
So I thought maybe the compiler sees that i'm extending ByteArray, but the
player doesn't ? And at this point I couldn't come up with any improvement or
workaround to make the class work. I tried to use the AS3 namespace as for when
overriding arrays, removing the override keyword... nothing that both the
compiler and player accepts.
I'm using Flex Builder 3 with the 3.2 framework, with the FP10 swc attached as
an external library.
So of anyone has a solution or a clue, I'd greatly appreciate it.
public class LockableByteArray extends ByteArray
{
private var _locked: Boolean;
public override function clear():void
{
if(_locked)
throw new IllegalOperationError("This byte array is read only");
super.clear();
}
}
|