pbjに日本語を突っ込んでみたのでテスト
pbjのバイナリをいじって日本語を
メタデータのdescriptionに突っ込んでみた。
FP 10.1RC ver.winのデバッグ版ではエラーなしです。
/**
* Copyright zahir ( http://wonderfl.net/user/zahir )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6dZw
*/
/*
pbjのバイナリをいじって日本語を
メタデータのdescriptionに突っ込んでみた。
FP 10.1RC ver.winのデバッグ版ではエラーなしです。
*/
package{
import com.actionscriptbible.Example;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.FileReference;
import flash.utils.ByteArray;
import mx.utils.Base64Decoder;
public class PBJ_a extends Example{
private var pbj:ByteArray;
public function PBJ_a(){
var dec:Base64Decoder = new Base64Decoder() ;
dec.decode(
"pQEAAACkFQBKYXBhbmVzZUxhbmd1YWdlX3Rlc3SgDG5hbWVzcGFjZQB6YWhpcjE5MjkAoAx2ZW5k" +
"b3IAemFoaXIAoAh2ZXJzaW9uAAEAoAxkZXNjcmlwdGlvbgDvu7/ml6XmnKzoqp7jga7ooajnpLrj" +
"g4bjgrnjg4jjgILjgbvjgZLjgbvjgZIAoQECAAAMX091dENvb3JkAKMABHNyYwChAgQBAA9kc3QA" +
"MAIA8QAAEAAdAQDzAgAbAA=="
);
pbj = dec.toByteArray();
pbj.position = 0;
trace( (new ShaderReader( pbj )).description );
}
}
}
import flash.utils.ByteArray;
import flash.display.Shader;
import flash.display.ShaderData;
import flash.display.ShaderParameter;
import flash.display.ShaderInput;
class ShaderReader{
static public const SORT_INDEX:String = "index";
static public const SORT_NAME:String = "name";
private var sd:ShaderData;
private var _bytes:ByteArray;
private var _input:Array = [];
private var _param:Array = [];
private var _name:String = "";
private var _namespace:String = "";
private var _vendor:String = "";
private var _version:String = "";
private var _description:String = "";
public function ShaderReader( bytes:ByteArray ){
sd = new Shader( bytes ).data;
_bytes = bytes;
for( var p:String in sd){
var d:* = sd[p];
if(d is ShaderParameter){
var sp:ShaderParameter = d as ShaderParameter;
var _values:Object = {};
for(var _d:String in sp){
_values[_d] = (sp[_d]) ? sp[_d] : "";
}
_param[_param.length] = {"name":p, "index":sp.indexm, "type":sp.type, "values":_values};
}else if(d is ShaderInput){
var si:ShaderInput = d as ShaderInput;
_input[_input.length] = {"name":p, "index":si.index, "channels":si.channels};
}else{
meta(p.toLowerCase(), d);
}
}
}
private function meta( paramName:String, paramData:String):void{
switch( paramName ){
case "name": _name = paramData; break;
case "namespace": _namespace = paramData; break;
case "vendor": _vendor = paramData; break;
case "version": _version = paramData; break;
case "description": _description = paramData; break;
}
}
public function get bytes():ByteArray{ return _bytes; }
// metaData
public function get name():String{ return _name; }
public function get nameSpace():String{ return _namespace; }
public function get vendor():String{ return _vendor; }
public function get version():String{ return _version; }
public function get description():String{ return _description;}
public function getInputData( sort:String = "index" ):Array{
_input.sortOn( sort , Array.CASEINSENSITIVE);
return _input;
}
public function getParamData( sort:String = "index" ):Array{
_param.sortOn( sort , Array.CASEINSENSITIVE);
return _param;
}
}