Adobe Dreamweaver Forums



Last 10 THreads :         Uncatchable Error 2101 (Last Post : M4G1C14N - Replies : 1 - Views : 2 )           »          File Transfer (Last Post : aruvasavi - Replies : 2 - Views : 3 )           »          Objects "Framed" when moving layer (Last Post : VegasMirage@adobeforums.com - Replies : 2 - Views : 3 )           »          Creating images to look like original oil paintings? (Last Post : Ian_Courtney@adobeforums.com - Replies : 0 - Views : 1 )           »          Opening a file in navpane from toolbar (Last Post : ChrisRousset - Replies : 0 - Views : 1 )           »          Help importing PNG sequence (Last Post : []MULISH - Replies : 0 - Views : 1 )           »          Problems importing PNG sequence (Last Post : []MULISH - Replies : 0 - Views : 1 )           »          Flash CS4 grey Icons in the Tool Panels are hard to see (Last Post : rnfw - Replies : 0 - Views : 1 )           »          Strip EXIF camera data from PSD files? (Last Post : Russell_Proulx@adobeforums.com - Replies : 2 - Views : 3 )           »          CSH Calls for Merged CHM's (Last Post : TrentSnake - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Labs > Flashplayer 10
 
Tags:



Reply
  #1 (permalink)  
Old 11-09-2008, 06:54 PM
Shtong2
 
Posts: n/a
Diggs:
Default 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();
}
}



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-22-2008, 01:55 AM
Reality Developer
 
Posts: n/a
Diggs:
Default Re: Extending ByteArray

I looked at this real quick... and the only thing I can tell you is that Flash
Player 9 ByteArray did not have a clear() method. Flash Player 10 ByteArray
does have a clear() method. I made a simple two code file test, where I'm
extending like you are from a ByteArray and I override the clear() method. When
I publish to fp9/as3 I get the error you have, because fp9 didn't have a
clear() in ByteArray and hence you can't override it. When I change it to fp10,
it compiles and runs just fine. So I would suggest to check that you're really
building a fp10 file. Other than that you have everything right... so somehow I
think your app is publishing to fp9. Hope this helps.

Reply With Quote
  #3 (permalink)  
Old 11-23-2008, 07:34 PM
Shtong2
 
Posts: n/a
Diggs:
Default Re: Extending ByteArray

Thanks for having a look. However I should have pointed out some other details :
- I make a heavy use of the Vector<> generic class, which is not included in
fp9 and works fine in my app, where overriding clear doesn't. (which proves I'm
correctly targetting FP10)
- The clear method was just an example here but I have the same problems with
inflate or deflate, which were available in FP9 too.

Reply With Quote


  #4 (permalink)  
Old 11-26-2008, 08:04 PM
Reality Developer
 
Posts: n/a
Diggs:
Default Re: Extending ByteArray

Well the use of the Vector<> class does prove you're in FP10, but Vector<>
doesn't have a clear() method to override either. It doesn't have a inflate or
deflate either. Not sure what class you were referring to, but Vector<> doesn't
have those methods hence you can't override them. You should check what methods
the core classes have that you can override at
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/
Good luck.

Reply With Quote
  #5 (permalink)  
Old 11-28-2008, 01:14 PM
Shtong2
 
Posts: n/a
Diggs:
Default Re: Extending ByteArray

I'm not saying I tried to override Vector. I just use it successfully, which
means I target the FP10 compiler and player as I should (because Vector has
been introduced with FP10). So the problem is not a wrong version problem.
Also, the ByteArray exposes inflate, deflate, that existed in FP9, and displays
the same error messages when I try to override them.

Reply With Quote
  #6 (permalink)  
Old 12-02-2008, 12:34 AM
Reality Developer
 
Posts: n/a
Diggs:
Default Re: Extending ByteArray

I'm not sure where you're getting that ByteArray has or had a inflate or
deflate... in FP9, because it didn't. It does in FP10, and I can override them
just fine. clear() also overrides just fine for me. When running this is will
print two traces: "byte array created" and "byte array cleared".


package
{
import flash.display.MovieClip;
import MyByteArray;

public class DocClass extends MovieClip
{
public var clip:MovieClip;

public function DocClass()
{
var b:MyByteArray = new MyByteArray();
}
}
};

package
{
import flash.utils.ByteArray;

public class MyByteArray extends ByteArray
{
public function MyByteArray()
{
super();

trace( "byte array created" );

clear();
}

override public function clear():void
{
trace( "byte array cleared" );
}
}
};

Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 04:37 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk