0

I am writing class that extends adobe air PNGEncoder,

I want to use the writeChunk method, but it seems to be private static and i cant seems to use it with my code But it gives the error as below

ERROR : Description Resource Path Location Type 1061: Call to a possibly undefined method writeChunk through a reference with static type com.adobe.images:PNGEncoder. pngMethods.as /FOTO_WITH_AS3_1/src/xmp line 121 Flex Problem

My class

public class pngMethods extends PNGEncoder
{

    public function pngMethods()
    {
        super();            
    }
    public function myMethod(pngOutput:ByteArray,IHDRByteArray:ByteArray):void
    {
        super.writeChunk(pngOutput,0x49484452,IHDRByteArray);
    }
}

Adobe PNG METHOD

    private static var crcTable:Array;
    private static var crcTableComputed:Boolean = false;

    private static function writeChunk(png:ByteArray, 
            type:uint, data:ByteArray):void {
        if (!crcTableComputed) {
            crcTableComputed = true;
            crcTable = [];
            var c:uint;
            for (var n:uint = 0; n < 256; n++) {
                c = n;
                for (var k:uint = 0; k < 8; k++) {
                    if (c & 1) {
                        c = uint(uint(0xedb88320) ^ 
                            uint(c >>> 1));
                    } else {
                        c = uint(c >>> 1);
                    }
                }
                crcTable[n] = c;
            }
        }
        var len:uint = 0;
        if (data != null) {
            len = data.length;
        }
        png.writeUnsignedInt(len);
        var p:uint = png.position;
        png.writeUnsignedInt(type);
        if ( data != null ) {
            png.writeBytes(data);
        }
        var e:uint = png.position;
        png.position = p;
        c = 0xffffffff;
        for (var i:int = 0; i < (e-p); i++) {
            c = uint(crcTable[
                (c ^ png.readUnsignedByte()) & 
                uint(0xff)] ^ uint(c >>> 8));
        }
        c = uint(c^uint(0xffffffff));
        png.position = e;
        png.writeUnsignedInt(c);
Engineer
  • 47,849
  • 12
  • 88
  • 91
user1004413
  • 2,509
  • 6
  • 23
  • 33

1 Answers1

1

Private methods are invisible to the outside world -- even inheritance won't do.

kasavbere
  • 5,873
  • 14
  • 49
  • 72
  • so only way is to copy and paste the method? – user1004413 Mar 18 '12 at 02:23
  • or see if you can make it public. – crooksy88 Mar 18 '12 at 06:29
  • if only your subclass will be accessing that function you should change the function's access modifier to `protected` instead of `public`. after you change the access modifier you can call the function like this: `PNGEncoder.writechunk(pngOutput,0x49484452,IHDRByteArray)` since the function is static. – Chunky Chunk Mar 18 '12 at 16:33
  • its adobe air class. so i doubt i can change it to public. it wouldn't let me make changes. – user1004413 Mar 19 '12 at 00:25