user1004413
user1004413

Reputation: 2619

How to use private static methods from another class

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);

Upvotes: 0

Views: 486

Answers (1)

kasavbere
kasavbere

Reputation: 6003

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

Upvotes: 1

Related Questions