Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The best way to do this is by using one of the libraries bhups suggested. I used <a href="http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/SWFReader.as" rel="nofollow noreferrer">senocular's</a> for the next example. Also, because the senocular's library provides only basic operations for the parsed SWF you may need the SWF Format Spec (adobe.com/devnet/swf/pdf/swf_file_format_spec_v10.pdf) to get the info you want out of the loaded SWF.</p> <p>The next example lists all the class names from a loaded SWF:</p> <pre><code>package swf { import flash.events.Event; import flash.net.URLRequest; import flash.net.URLStream; import flash.utils.ByteArray; import flash.utils.Endian; import swf.SWFReader; public class GetSWFInfo { private var swfInfo:SWFReader; public function GetSWFInfo() { var urlRequest:URLRequest = new URLRequest("theswf.swf"); var loader:URLStream = new URLStream(); loader.load(urlRequest); loader.addEventListener(Event.COMPLETE, onComplete); } public function onComplete(e:Event):void { var recivedByteArray :ByteArray = new ByteArray(); URLStream(e.currentTarget).readBytes(recivedByteArray); //create a new instance of SWFReader swfInfo = new SWFReader(); //readTag it's a callback function that will be called when a tag is read during the SWF parse process. //read more on tags in the SWF specification document swfInfo.tagCallback = readTag; //start parsing swfInfo.parse(recivedByteArray); } public function readTag(tag:uint, bytes:ByteArray):void { //76 it's the tag type for SymbolClass tag //read more in the SWF specification document if (76 == tag) { var classesArray:Array = new Array(); var symbolsNumber:uint = 0; var currentId:uint = 0; bytes.endian = Endian.LITTLE_ENDIAN; //read the symbols Number //again read more in the SWF specification document symbolsNumber = bytes.readShort(); bytes.position = 4; while (true) { var i:uint = bytes.position; //every string name ends with a null byte //again read more in the SWF specification document while(bytes[i] != 0) i++; var readAmount:uint = i - bytes.position; classesArray.push(bytes.readUTFBytes(readAmount)); //the last ID is always the base class Id, and it's 0 currentId=bytes.readUnsignedShort(); bytes.position++; if (currentId==0) { break; } } //this two should be equal trace(classesArray.length + 1);//the number of elements in the classesArray trace(symbolsNumber);//the number of classes retrived from the SWF //list the names var name:String; for each (name in classesArray) { trace(name); } //now you have an array with all the class names that you can use to compare } } } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload