Beispiel #1
0
 function parse($swfdata)
 {
     $reader = new IO_Bit();
     $reader->input($swfdata);
     $this->_swfdata = $swfdata;
     /* SWF Header */
     $this->_headers['Signature'] = $reader->getData(3);
     $this->_headers['Version'] = $reader->getUI8();
     $this->_headers['FileLength'] = $reader->getUI32LE();
     if ($this->_headers['Signature'][0] == 'C') {
         // CWS の場合、FileLength の後ろが zlib 圧縮されている
         $uncompressed_data = gzuncompress(substr($swfdata, 8));
         if ($uncompressed_data === false) {
             return false;
         }
         list($byte_offset, $dummy) = $reader->getOffset();
         $reader->setOffset(0, 0);
         $swfdata = $reader->getData($byte_offset) . $uncompressed_data;
         $reader = new IO_Bit();
         $reader->input($swfdata);
         $this->_swfdata = $swfdata;
         $reader->setOffset($byte_offset, 0);
     }
     /* SWF Movie Header */
     $this->_headers['FrameSize'] = IO_SWF_Type_RECT::parse($reader);
     $reader->byteAlign();
     $this->_headers['FrameRate'] = $reader->getUI16LE();
     $this->_headers['FrameCount'] = $reader->getUI16LE();
     list($this->_header_size, $dummy) = $reader->getOffset();
     /* SWF Tags */
     while (true) {
         $swfInfo = array('Version' => $this->_headers['Version']);
         $tag = new IO_SWF_Tag($swfInfo);
         $tag->parse($reader);
         $this->_tags[] = $tag;
         if ($tag->code == 0) {
             // END Tag
             break;
         }
     }
     return true;
 }
Beispiel #2
0
 function insertAction($sprite_id, $frame, $pos, $action)
 {
     if ($sprite_id == 0) {
         $tags =& $this->_tags;
     } else {
         $sprite = $this->findSprite($sprite_id);
         if (!$sprite) {
             return null;
         }
         $tags =& $sprite->tag->_controlTags;
     }
     $action_tag = $this->findActionTagInTags($frame, $tags);
     if (!$action_tag) {
         if ($pos > 1) {
             // 1 origin
             return null;
         }
         $currentFrame = 0;
         $found = false;
         foreach ($tags as $tagidx => $tag) {
             if ($tag->code == 1) {
                 $currentFrame++;
             }
             if ($currentFrame >= $frame) {
                 $found = true;
                 break;
             }
         }
         if ($found === false) {
             return null;
         }
         $action_tag = new IO_SWF_Tag($tags[0]->swfInfo);
         $action_tag->code = 12;
         // DoAction
         $action_tag->content = '';
         $action_tag->parseTagContent();
         $action_tag->content = null;
         array_splice($tags, $tagidx, 0, array($action_tag));
     }
     $action_tag->tag->insertAction($pos, $action);
     return true;
 }