我想知道如何使用PHP基本編輯.swf文件,以更改單個變量或更改。我會如何去做這件事?有沒有辦法在不知道機器碼的情況下編輯它?使用PHP寫入.swf文件
如果有一個如何做到這一點的例子,我可以在哪裏找到它?
謝謝!
或者,如果有更簡單的方法去做這件事,請讓我知道!
我想知道如何使用PHP基本編輯.swf文件,以更改單個變量或更改。我會如何去做這件事?有沒有辦法在不知道機器碼的情況下編輯它?使用PHP寫入.swf文件
如果有一個如何做到這一點的例子,我可以在哪裏找到它?
謝謝!
或者,如果有更簡單的方法去做這件事,請讓我知道!
問題是舊的,但由於它恰好與我一直在努力的一致,所以我想我會把東西放在一起,以防其他人發現它有用。該解決方案僅適用於AS3。它可以讓你改變實例變量和常量的值。
假設你有下面的類:
package pl.krakow.rynek {
import flash.display.Sprite;
public class Advertisement extends Sprite {
private var title:String = 'Euro 2012 LIVE!';
/* ... */
}
}
你想要的VAR 標題別的東西。這樣做的代碼如下:
<?php
require_once 'flaczki/classes.php';
// parse the SWF file, decoding only those tags needed by the injector
$input = fopen("input.swf", "rb");
$parser = new SWFParser;
$injector = new AS3ConstantInjector;
$swfFile = $parser->parse($input, $injector->getRequiredTags());
$classConstants = array(
'pl.krakow.rynek.Advertisement' => array(
'title' => 'Free Beer!'
)
);
// inject the values and reassemble the file
$injector->inject($swfFile, $classConstants);
$output = fopen($outPath, "wb");
$assembler = new SWFAssembler;
$assembler->assemble("output.swf", $swfFile);
?>
該代碼應該是不言自明的。首先分析SWF文件,進行修改,並將內存結構保存到文件中。 AS3ConstantInjector.inject()期望作爲第二個參數的數組,該數組由你想要修改的類的限定名鍵控。數組本身爲每個類保存新值,其中鍵爲變量/常量名。
要查看的SWF文件中的變量,使用AS3ConstantExtractor:
<?php
require_once 'flaczki/classes.php';
$input = fopen("button.swf", "rb");
$parser = new SWFParser;
$extractor = new AS3ConstantExtractor;
$swfFile = $parser->parse($input, $extractor->getRequiredTags());
$classConstants = $extractor->extract($swfFile);
print_r($classConstants);
?>
的Flaczki類可以在http://code.google.com/p/flaczki/downloads/list
下載,您可以找到更多關於Flaczki框架在項目開發的博客http://flaczkojad.blogspot.com/
使用libming寫入閃存文件的數據是否與之保持一致? – Cyclone 2009-08-30 16:32:25
檢查出SWF-library在PHP libming
PHP文件
而不是想着如何生成SWF文件,卻反其道而行之,讓內部行爲取決於PHP腳本中的外部邏輯。這樣你就不需要(重新)編譯你的swf。
非常好,謝謝! – Cyclone 2012-08-12 15:39:14