創建庫
可以使用Flex Builder或者Compc命令行來創建庫. 庫可以是一個SWC文件, 或者是包含了library.swf和catalog.xml文件的目錄. 一個庫通常包含自定義組件和類. 然后就可以在RSL中使用這些庫了.
在Flex Bulder中, 通過使用Flex Library Build Path對話框來添加資源到庫中.
在命令行中, 使用include-classes和include-namespaces選項來添加文件到庫中.
下面的命令行示例說明了如何創建一個名字叫CustomCellRenderer的庫:
compc -source-path ../mycomponents/components/local
-include-classes CustomCellRendererComponent -directory=true -debug=false
-output ../libraries/CustomCellRenderer
所有包含的組件必須是靜態鏈接的文件. 使用compc編譯器創建庫時, 不能使用include-file選項, 因為這個選項不是將library.swf文件靜態鏈接到庫中的.
可以使用directory選項指定輸出到一個目錄而不是到一個SWC文件中:
<?xml version="1.0">
<flex-config>
??? <compiler>
??????? <source-path>
??????????? <path-element>mycomponents/components/local</path-element>
??????? </source-path>
??? </compiler>
??? <output>libraries/CustomCellRenderer</output>
??? <directory>true</directory>
??? <debug>false</false>
??? <include-classes>
??????? <class>CustomCellRendererComponent</class>
??? </include-classes>
</flex-config>
輸出會是一個目錄,目錄里包含兩個文件
??? * catalog.xml
??? * library.swf
創建library.swf文件后, 你可以編譯應用并且指定文件的位置.