使用RSL(Runtime Shared Libraries)來(lái)減小Flex生成的SWF文件的大小(IV) -- 創(chuàng)建RSL
Posted on 2007-02-01 15:25 云自無(wú)心水自閑 閱讀(743) 評(píng)論(0) 編輯 收藏 所屬分類: Flex 、Flex2創(chuàng)建庫(kù)
可以使用Flex Builder或者Compc命令行來(lái)創(chuàng)建庫(kù). 庫(kù)可以是一個(gè)SWC文件, 或者是包含了library.swf和catalog.xml文件的目錄. 一個(gè)庫(kù)通常包含自定義組件和類. 然后就可以在RSL中使用這些庫(kù)了.
在Flex Bulder中, 通過(guò)使用Flex Library Build Path對(duì)話框來(lái)添加資源到庫(kù)中.
在命令行中, 使用include-classes和include-namespaces選項(xiàng)來(lái)添加文件到庫(kù)中.
下面的命令行示例說(shuō)明了如何創(chuàng)建一個(gè)名字叫CustomCellRenderer的庫(kù):
compc -source-path ../mycomponents/components/local
-include-classes CustomCellRendererComponent -directory=true -debug=false
-output ../libraries/CustomCellRenderer
所有包含的組件必須是靜態(tài)鏈接的文件. 使用compc編譯器創(chuàng)建庫(kù)時(shí), 不能使用include-file選項(xiàng), 因?yàn)檫@個(gè)選項(xiàng)不是將library.swf文件靜態(tài)鏈接到庫(kù)中的.
可以使用directory選項(xiàng)指定輸出到一個(gè)目錄而不是到一個(gè)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>
輸出會(huì)是一個(gè)目錄,目錄里包含兩個(gè)文件
??? * catalog.xml
??? * library.swf
創(chuàng)建library.swf文件后, 你可以編譯應(yīng)用并且指定文件的位置.