powered by nequal
Home » IO_SWF » Timeline » 2486

Changeset 2486 -- 2011-06-10 18:55:50

Author
よや
Comment
DefineSprite 対応 parse/build/dump

Diffs

IO_SWF/trunk/IO/SWF/Tag.php

@@ -46,7 +46,7 @@
36 => array('name' => 'DefineBitsLossless2'),
37 => array('name' => 'DefineEditText'),
// 38 missing
-            39 => array('name' => 'DefineSprite'),
+            39 => array('name' => 'DefineSprite', 'klass' => 'Sprite'),
// 40,41,42 missing
43 => array('name' => 'FrameLabel'),
// 44 missing

IO_SWF/trunk/IO/SWF/Tag/Action.php

@@ -23,7 +23,7 @@
}
function dumpContent($tagCode, $opts = array()) {
-        echo "  Actions:\n";
+        echo "    Actions:\n";
foreach ($this->_actions as $action) {
$action_str = IO_SWF_Type_Action::string($action);
echo "\t$action_str\n";

IO_SWF/trunk/IO/SWF/Tag/Sprite.php

@@ -0,0 +1,49 @@
+<?php
+
+require_once 'IO/Bit.php';
+require_once dirname(__FILE__).'/Base.php';
+require_once dirname(__FILE__).'/../Tag.php';
+
+class IO_SWF_Tag_Sprite extends IO_SWF_Tag_Base {
+    var $_spriteId = null;
+    var $_frameCount = null;
+    var $_controlTags = array();
+    function parseContent($tagCode, $content, $opts = array()) {
+        $reader = new IO_Bit();
+    	$reader->input($content);
+
+        $this->_spriteId = $reader->getUI16LE();
+        $this->_frameCount = $reader->getUI16LE();
+        /* SWF Tags */
+        while (true) {
+            $tag = new IO_SWF_Tag();
+            $tag->parse($reader);
+            $this->_controlTags[] = $tag;
+            if ($tag->code == 0) { // END Tag
+                break;
+            }
+        }
+        return true;
+    }
+
+    function dumpContent($tagCode, $opts = array()) {
+        echo "\tSprite: SpriteID={$this->_spriteId} FrameCount={$this->_frameCount}\n";
+        foreach ($this->_controlTags as $tag) {
+            echo "  ";
+            $tag->dump($opts);
+        }
+    }
+
+    function buildContent($tagCode, $opts = array()) {
+        $writer = new IO_Bit();
+        $writer->putUI16LE($this->_spriteId);
+        $writer->putUI16LE($this->_frameCount);
+        foreach ($this->_controlTags as $tag) {
+            $tagData = $tag->build();
+            if ($tagData != false) {
+                $writer->putData($tag->build());
+            }
+        }
+    	return $writer->output();
+    }
+}