                     }
                     if (_curId3PES) {
                         // store data.  will normally be in a single TS
-                        _curId3PES.writeBytes(_data, _data.position, todo);
+                        _curId3PES.writeBytes(data, data.position, todo);
                         var pes : PES = new PES(_curId3PES);
                         if (pes.len && (pes.data.length - pes.payload - pes.payload_len) >= 0) {
                             CONFIG::LOGGING {

            return (_pmtParsed == false || _avcId != -1);
        }

        /** Parse a limited amount of packets each time to avoid blocking **/
        private function _parseTimer(e : Event) : void {
            var start_time : int = getTimer();
            _data.position = _read_position;
            // dont spend more than 20ms demuxing TS packets to avoid loosing frames
            while ((_data.bytesAvailable >= 188) && ((getTimer() - start_time) < 20)) {
                _parseTSPacket();
            }
            if (_tags.length) {
                _callback_progress(_tags);
                _tags = new Vector.<FLVTag>();
            }
            if (_data) {
                _read_position = _data.position;
                // finish reading TS fragment
                if (_data_complete && _data.bytesAvailable < 188) {
                    // free ByteArray
                    _data = null;
                    // first check if TS parsing was successful
                    CONFIG::LOGGING {
                        if (_pmtParsed == false) {
                            Log.error("TS: no PMT found, report parsing complete");
                        }
                    }
                    _displayObject.removeEventListener(Event.ENTER_FRAME, _parseTimer);
                    _flush();
                    _callback_complete();
                }
            }
        }


            // Parse the PES, split by Packet ID.
            switch (pid) {
                case PAT_ID:
                    todo -= _parsePAT(stt,data);
                    CONFIG::LOGGING {
                        if (_pmtParsed == false) {
                            Log.debug("TS: PAT found.PMT PID:" + _pmtId);
