forked from: SWF Header Reader
SWF のバージョンなどをチェックするやつ。
/**
* Copyright bkzen ( http://wonderfl.net/user/bkzen )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rsRD
*/
// forked from bkzen's SWF Header Reader
/**
* SWF のバージョンなどをチェックするやつ。
*/
package
{
import flash.net.URLRequest;
import flash.net.URLLoaderDataFormat;
import flash.net.URLLoader;
import com.bit101.components.HBox;
import com.bit101.components.InputText;
import com.bit101.components.Label;
import com.bit101.components.PushButton;
import com.bit101.components.Window;
import flash.events.Event;
import flash.display.Sprite;
import flash.net.FileFilter;
import flash.net.FileReference;
import org.libspark.swfassist.io.ByteArrayInputStream;
import org.libspark.swfassist.io.DataInput;
import org.libspark.swfassist.swf.io.ReadingContext;
import org.libspark.swfassist.swf.io.SWFReader;
import org.libspark.swfassist.swf.structures.SWF;
[SWF (backgroundColor = "0xFFFFFF", frameRate = "30", width = "465", height = "465")]
public class FlashTest extends Sprite
{
private var loader:URLLoader;
private var btn:PushButton;
private var urlInput:InputText;
private var resultWindow:Window;
private var frameRate:InputText;
private var frameSize:InputText;
private var numFrames:InputText;
private var swfVersion:InputText;
public function FlashTest()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e: Event = null): void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//
var hbox: HBox, label: Label;
hbox = new HBox(this);
urlInput = new InputText(hbox, 0, 0, "http://swf.wonderfl.net/swf/usercode/c/cb/cbf9/cbf98a508f7466c48d984dd6e79bfcefe01f01da.swf");
btn = new PushButton(hbox, 0, 0, "load swf", onClick);
resultWindow = new Window(this, 165 / 2, 165 / 2, "Result");
resultWindow.setSize(300, 300);
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, onComp);
hbox = new HBox(resultWindow.content);
hbox.spacing = 10;
hbox.move(20, 20);
label = new Label(hbox, 0, 0, "Frame Rate : ");
frameRate = new InputText(hbox, 0, 0, "");
frameRate.enabled = false;
hbox = new HBox(resultWindow.content);
hbox.spacing = 10;
hbox.move(20, 50);
label = new Label(hbox, 0, 0, "Frame Size : ");
frameSize = new InputText(hbox, 0, 0, "");
frameSize.enabled = false;
hbox = new HBox(resultWindow.content);
hbox.spacing = 10;
hbox.move(20, 80);
label = new Label(hbox, 0, 0, "Num of Frames : ");
numFrames = new InputText(hbox, 0, 0, "");
numFrames.enabled = false;
hbox = new HBox(resultWindow.content);
hbox.spacing = 10;
hbox.move(20, 110);
label = new Label(hbox, 0, 0, "SWF Version : ");
swfVersion = new InputText(hbox, 0, 0, "");
swfVersion.enabled = false;
}
private function onClick(e: Event):void
{
loader.load(new URLRequest(urlInput.text));
}
private function onComp(e: Event): void
{
var input: DataInput = new ByteArrayInputStream(loader.data);
var context: ReadingContext = new ReadingContext();
var reader: SWFReader = new SWFReader();
var swf: SWF = reader.readSWF(input, context);
frameRate.text = "" + swf.header.frameRate;
frameSize.text = swf.header.frameSize.xMin + " " + swf.header.frameSize.xMax + " " +
swf.header.frameSize.yMin + " " + swf.header.frameSize.yMax;
numFrames.text = "" + swf.header.numFrames;
swfVersion.text = "" + swf.header.version;
addChild(btn);
}
}
}