 
         COMPILE::JS
         {
-            setBufferSize(ba.byteLength + extra);
+            setBufferSize(_len + extra);
         }
     }
 
     COMPILE::JS
     protected function ensureWritableBytes(len:uint):void{
-        if (_position + len > ba.byteLength) {
+        if (_position + len > _len) {
             setBufferSize( _position + len );
         }
     }

    public function BinaryData(bytes:ArrayBuffer = null)
    {
        ba = bytes ? bytes : new ArrayBuffer(0);
    }

    /**

            ba = newView.buffer;
            if (_position > newSize) _position = newSize;
            _typedArray = newView;
            _len = newSize;
        }
    }
    /**
