解决方法
是的,您需要查看二进制swf数据.
Here是swf格式的简要说明.
this是关于不同类型标签的一些细节.您的要求是找出SetBackgroundColor标记(标记类型= 9),它通常是swf的第一个或第二个标记. swf文件中的字节遵循小端序,因此在读取数据时需要小心.并且大多数它们将被压缩(前三个字节将是“CWS”)所以从第9个字节开始(包括第9个),所有数据需要在处理之前解压缩(ByteArray.decompress).一些示例代码:)
package { import flash.display.*; import flash.events.*; import flash.net.*; import flash.utils.*; public class Test1 extends Sprite{ private var stream:URLStream; public function Test1():void { stream = new URLStream(); stream.load(new URLRequest("some.swf")); stream.addEventListener(Event.COMPLETE,onComplete); } private function onComplete(e:Event):void { var bytes:ByteArray = new ByteArray(); bytes.endian = Endian.LITTLE_ENDIAN; stream.readBytes(bytes,8); var sig:String = bytes.readUTFBytes(3); trace("SIG = " + sig); trace("ver = " + bytes.readByte()); trace("size = " + bytes.readUnsignedInt()); var compBytes:ByteArray = new ByteArray(); compBytes.endian = Endian.LITTLE_ENDIAN; stream.readBytes(compBytes); if (sig == "CWS") { compBytes.uncompress(); } var fbyte = compBytes.readUnsignedByte(); var rect_bitlength = fbyte >> 3; var total_bits = rect_bitlength * 4; var next_bytes = Math.ceil((total_bits - 3)/ 8); for(var i=0; i<next_bytes; i++) { compBytes.readUnsignedByte(); } trace("frameRate = " + compBytes.readUnsignedShort()); trace("frameCount = " + compBytes.readUnsignedShort());while(true) { var tagcodelen:Number = compBytes.readUnsignedShort(); var tagcode:Number = tagcodelen >> 6; var taglen:Number = tagcodelen & 0x3F; trace("tag code = " + tagcode + "\tlen = " + taglen); if (taglen >=63) { taglen = compBytes.readUnsignedInt(); } if(tagcode == 9) { trace("found background color"); trace("color is: RED=" + compBytes.readUnsignedByte() +",GREEN = " + compBytes.readUnsignedByte() + ",BLUE = " + compBytes.readUnsignedByte()); break; } compBytes.readBytes(new ByteArray(),taglen); //break; } }
}}
while(true) { var tagcodelen:Number = compBytes.readUnsignedShort(); var tagcode:Number = tagcodelen >> 6; var taglen:Number = tagcodelen & 0x3F; trace("tag code = " + tagcode + "\tlen = " + taglen); if (taglen >=63) { taglen = compBytes.readUnsignedInt(); } if(tagcode == 9) { trace("found background color"); trace("color is: RED=" + compBytes.readUnsignedByte() +",taglen); //break; } }