SWC是flex的库文件,对应于Java的jar文件。
和jar文件一样,SWC文件也是一个简单的ZIP文件。我们可以用7zip等解压缩工具打开它。
SWC文件的构造如下所示
SWC
-------catalog.xml
-------libary.swf
-------locale目录(可选)
等等
其中catalog.xml描述了swf里的类信息。
一个简单的catalog.xml可能包含下列信息:
版本信息:
<versions> <swc version="1.2" /> <flex version="3.2.0" build="3958" /> </versions>
feature信息,尚未了解其中tag代表的含义
<features> <feature-script-deps /> <feature-components /> <feature-files /> </features>
libraries标签代表SWC中所包含的swf文件,典型的文件名是library.swf,script标签代表了用斜杠分割的类名。
<libraries>
<library path="library.swf">
<script name="mx/core/mx_internal" mod="1225427288988" signatureChecksum="2693670951">
<library path="library.swf">
<script name="mx/core/mx_internal" mod="1225427288988" signatureChecksum="2693670951">
上述script的一个典型格式如下
<script name="com/test/Employee" mod="1228811323437" signatureChecksum="185354909"> <def id="com.test:Employee" /> <dep id="com.test:Base" type="i" /> <dep id="com.test:IEmployee" type="i" /> <dep id="AS3" type="n" /> <dep id="mx.collections:ArrayCollection" type="s" /> <dep id="com.test:DynamicClass" type="s" /> <dep id="mx.collections:ArrayCollection" type="e" /> <dep id="trace" type="e" /> <dep id="com.test:DynamicClass" type="e" /> </script>
def标签代表了Actionscript3格式的类名,dep标签代表了这个类所依赖的其他类,我们看到有不同的type,很显然i代表inheritance, n代表namespace, s所指的class都是我在这个Employee类中所使用的其他类。 而e我还不是很了解所代表的意思。
keep-as3-metadata所指代的应该是类的默认的metadata
<keep-as3-metadata> <metadata name="Managed" /> <metadata name="ChangeEvent" /> <metadata name="Transient" /> <metadata name="NonCommittingChangeEvent" /> <metadata name="Bindable" /> </keep-as3-metadata>
digiests标签显然代表这个swf文件的SHA-256检验值。
<digests> <digest type="SHA-256" signed="false" value="319d1e313b334928de34eb5c655fecf3a035d989fb8855c9c5c77780cfb7c26b" /> </digests>
files标签标示了在SWC中的一些资源文件。
<files> <file path="locale/en_US/collections.properties" mod="1225427279566" /> </files>
附录:
这个Employee.as的内容
package com.test
{
import mx.collections.ArrayCollection;
public class Employee extends Base implements IEmployee
{
public function read():void{
var col:ArrayCollection = new ArrayCollection();
trace("read");
}
public function Employee()
{
var dc:DynamicClass = new DynamicClass();
}
}
}