<?php

require_once('BitStream.php');

$TagNameTable = array(=> 'End',
              
=> 'ShowFrame',
              
=> 'DefineShape',
              
=> 'DefineBitsJPEG',
              
=> 'JPEGTables',
              
=> 'SetBackgroundColor',
              
12 =>'DoAction',
              
26 =>'PlaceObject2'
              
);

class 
FlashSWF_TagBlock {
  private 
$_tag;
  private 
$_length;
  private 
$_length_longformat;
  private 
$_rawdata;
  function 
__construct(&$ibs) {
      
$tag_and_length $ibs->getBytesLE(2); // important
      
$tag $tag_and_length >> 6;
      
$length $tag_and_length 0x3f;
      if (
$length == 0x3f) {
              
$this->_length_longformat true
              
$length $ibs->getBytesLE(4);
      }
      
$this->_tag $tag;
      
$this->_length $length;
      
$this->_rawdata $ibs->getStrings($length);
  }
  function 
getTagName() {
    global 
$TagNameTable;
    
$tag $this->_tag;
    if (isset(
$TagNameTable[$tag])) {
      return 
$TagNameTable[$tag] . "($tag)";
    }
    return 
$tag;
  }
  function 
getTagId() {
    return 
$this->_tag;
  }
  function 
getLength() {
    return 
$this->_length;
  }
  function 
getData() { // must be override
    
return $this->_rawdata;
  }
}