Exemple #1
0
 function parseContent($tagCode, $content, $opts = array())
 {
     $reader = new IO_Bit();
     $reader->input($content);
     $this->_buttonId = $reader->getUI16LE();
     $opts['tagCode'] = $tagCode;
     if ($tagCode == 34) {
         // DefineButton2
         $this->_reservedFlags = $reader->getUIBits(7);
         $this->_trackAsMenu = $reader->getUIBit();
         list($offset_actionOffset, $dummy) = $reader->getOffset();
         $this->_actionOffset = $reader->getUI16LE();
     }
     $characters = array();
     while ($reader->getUI8() != 0) {
         $reader->incrementOffset(-1, 0);
         // 1 byte back
         $characters[] = IO_SWF_Type_BUTTONRECORD::parse($reader, $opts);
     }
     $this->_characters = $characters;
     if ($tagCode == 34) {
         // DefineButton2
         // TODO: skip ActionOffset - CurrentOffsetUntilCharactersField
         $actions = array();
         if ($this->_actionOffset > 0) {
             list($offset_buttonCondition, $dummy) = $reader->getOffset();
             if ($offset_actionOffset + $this->_actionOffset != $offset_buttonCondition) {
                 // TODO: warning
                 $reader->setOffset($offset_actionOffset + $this->_actionOffset, 0);
             }
             while (true) {
                 $action = IO_SWF_Type_BUTTONCONDACTION::parse($reader, $opts);
                 $actions[] = $action;
                 if ($action['CondActionSize'] == 0) {
                     break;
                     // last action
                 }
             }
             $this->_actions = $actions;
         } else {
             $this->_actions = null;
         }
     } else {
         $actions = array();
         while ($reader->getUI8() != 0) {
             $reader->incrementOffset(-1, 0);
             // 1 byte back
             $actions[] = IO_SWF_Type_Action::parse($reader);
         }
         $this->_actions = $actions;
     }
     return true;
 }
Exemple #2
0
 function parseContent($tagCode, $content, $opts = array())
 {
     $reader = new IO_Bit();
     $reader->input($content);
     if ($tagCode == 59) {
         // DoInitAction
         $this->_spriteId = $reader->getUI16LE();
     }
     $i = 0;
     while ($reader->hasNextData(1)) {
         list($byteOffset, $dummy) = $reader->getOffset();
         $action = IO_SWF_Type_Action::parse($reader);
         list($nextByteOffset, $dummy) = $reader->getOffset();
         //
         $this->_byteOffsetTable[$i] = $byteOffset;
         $this->_byteSizeTable[$i] = $nextByteOffset - $byteOffset;
         $recordOffsetToByteOffset[$i] = $byteOffset;
         $byteOffsetToRecordOffset[$byteOffset] = $i;
         //
         $this->_actions[] = $action;
         $i++;
     }
     if ($i > 0) {
         $recordOffsetToByteOffset[$i] = $nextByteOffset;
         $byteOffsetToRecordOffset[$nextByteOffset] = $i;
         $byteOffsetToRecordOffset[$nextByteOffset] = $i;
     }
     $label_num = 0;
     foreach ($this->_actions as $i => $action) {
         if ($action['Code'] == 0x99) {
             // Jump
             $branch_offset = $action['BranchOffset'];
         } else {
             if ($action['Code'] == 0x9d) {
                 // If
                 $branch_offset = $action['Offset'];
             } else {
                 continue;
             }
         }
         $targetByteOffset = $recordOffsetToByteOffset[$i + 1] + $branch_offset;
         if (isset($byteOffsetToRecordOffset[$targetByteOffset])) {
             $targetRecordOffset = $byteOffsetToRecordOffset[$targetByteOffset];
             if (isset($this->_labels[$targetRecordOffset]) === false) {
                 $this->_labels[$targetRecordOffset] = $targetRecordOffset;
             }
             $this->_branches[$i] = $this->_labels[$targetRecordOffset];
         }
     }
 }
Exemple #3
0
 static function parse(&$reader, $opts = array())
 {
     $clipactionrecord = array();
     $clipactionrecord['EventFlags'] = IO_SWF_Type_CLIPEVENTFLAGS::parse($reader, $opts);
     $clipactionrecord['ActionRecordSize'] = $reader->getUI32LE();
     if ($clipactionrecord['EventFlags']['ClipEventKeyPress'] == 1) {
         $clipactionrecord['KeyCode'] = $reader->getUI8();
     }
     $actions = array();
     while ($reader->getUI8() != 0) {
         $reader->incrementOffset(-1, 0);
         // 1 byte back
         $action = IO_SWF_Type_Action::parse($reader);
         $actions[] = $action;
     }
     $clipactionrecord['Actions'] = $actions;
     return $clipactionrecord;
 }
Exemple #4
0
 static function parse(&$reader, $opts = array())
 {
     $condAction = array();
     $condAction['CondActionSize'] = $reader->getUI16LE();
     foreach (self::$buttoncond_list as $key) {
         $condAction['Cond' . $key] = $reader->getUIBit();
     }
     $condAction['CondKeyPress'] = $reader->getUIBits(7);
     $condAction['CondOverDownToIdle'] = $reader->getUIBit();
     if ($reader->hasNextData()) {
         // XXX (depends on ActionOffset
         $actions = array();
         while ($reader->getUI8() != 0) {
             $reader->incrementOffset(-1, 0);
             // 1 byte back
             $actions[] = IO_SWF_Type_Action::parse($reader);
         }
         $condAction['Actions'] = $actions;
     }
     return $condAction;
 }