powered by nequal
Home » IO_SWF » Timeline » 2448

Changeset 2448 -- 2011-04-19 22:50:32

Author
よや
Comment
SetBackgroundColor タグ対応

Diffs

IO_SWF/trunk/IO/SWF/Tag.php

@@ -1,6 +1,5 @@
<?php
-
require_once dirname(__FILE__).'/../SWF.php';
class IO_SWF_Tag {
@@ -20,7 +19,7 @@
6 => array('name' => 'DefineBitsJPEG'),
7 => array('name' => 'DefineButton'),
8 => array('name' => 'JPEGTables'),
-             9 => array('name' => 'SetBackgroundColor'),
+             9 => array('name' => 'SetBackgroundColor', 'klass' => 'BGColor'),
10 => array('name' => 'DefineFont'),
11 => array('name' => 'DefineText'),
12 => array('name' => 'DoAction'),
@@ -110,13 +109,12 @@
}
function dump($opts = array()) {
$code = $this->code;
-        $length = strlen($this->content);
$name = $this->getTagInfo($code, 'name');
if ($name === false) {
$name = 'unknown';
}
+        $length = strlen($this->content);
echo "Code: $code($name)  Length: $length".PHP_EOL;
-        $klass = self::getTagInfo($code, 'klass');
if ($this->parseTagContent()) {
$this->tag->dumpContent($code);
}
@@ -154,7 +152,7 @@
return $writer->output() . $this->buildTagContent();
}
function parseTagContent() {
-            if (is_null($this->tag) === false) {
+        if (is_null($this->tag) === false) {
return true;
}
$code = $this->code;
@@ -162,6 +160,7 @@
if ($klass === false) {
return false; // no parse
}
+        require_once dirname(__FILE__)."/Tag/$klass.php";
$klass = "IO_SWF_Tag_$klass";
$obj = new $klass();
$obj->parseContent($code, $this->content);

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

@@ -0,0 +1,26 @@
+<?php
+
+require_once 'IO/Bit.php';
+require_once dirname(__FILE__).'/Base.php';
+require_once dirname(__FILE__).'/../Type/RGB.php';
+
+class IO_SWF_Tag_BGColor extends IO_SWF_Tag_Base {
+    var $_color;
+
+   function parseContent($tagCode, $content, $opts = array()) {
+        $reader = new IO_Bit();
+    	$reader->input($content);
+        $this->_color = IO_SWF_Type_RGB::parse($reader);
+    }
+
+    function dumpContent($tagCode, $opts = array()) {
+        $color_str = IO_SWF_Type_RGB::string($this->_color);
+        echo "\tColor: $color_str\n";
+    }
+
+    function buildContent($tagCode, $opts = array()) {
+        $writer = new IO_Bit();
+        IO_SWF_Type_RGB::parse($writer, $this->_color);
+    	return $writer->output();
+    }
+}