乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • Flex compc & ant 編譯

       地域-幽靈 2011-05-25

      當(dāng)我們的類庫在Flex Builder中可以編譯通過時,那自動化編譯(ant)主要是根據(jù)在Flex Builder中設(shè)置的參數(shù)一致,基本就可以采用compc命令編譯出一個swc文件。在編譯過程中可能會遇到各種問題,不過不要煩躁,找到每個問題的原因,自然就找到了解決辦法,下面總結(jié)一下在做Flex自動化編譯過程中遇到的問題,希望可以幫助到大家。

      在做ant編譯之前,先看一下工程的具體信息,右鍵工程—屬性,切換到Flex Library Build Path中,我們可以看到四個選項卡,Classes\Assers\Source Path\Library Path,那也就是說明我們用編寫腳本的時候只需要指定這四項就可以了,另外,在Flex Library Compiler中可以看到是en_US\zh_CN,證明要做中英文資源化,因此我們自動化編譯的時候需要將資源化文件引入,具體國際化會在后面介紹。

      1.    Flex Embed資源錯誤Unable to transcode asset處理

      <mx:Image id="img_border" source="@Embed('../assets/border.png')" visible="false" width="100%" height="100%"/>

      一段簡單的代碼flex編譯居然報錯:

      Unable to transcode ../assets/border.png.

      解決方法很簡單,

      將 '../assets/border.png' 改為 '/../assets/border.png'

      就是在前面加個斜杠。

      2.    Flex國際化

      首先先介紹下國際化:

      Flex國際化一般采用的是類似struts的bundle類似的方法,至于好處嘛會使用STRUTS的人都應(yīng)該知道。
      直接在項目中寫.properties文件,具體做法如下:
      在項目上點擊右鍵,選擇Properties。
      然后選擇Flex Compiler,在Additional Compiler arguments下面已經(jīng)配置好了語言包,

      默認(rèn)為-locale en_US。
      這時我們可以用一個locale目錄來簡單定制我們額外設(shè)置(當(dāng)然不包括Flex內(nèi)部控件的語言)的語言設(shè)置。
      比如改為:-locale=en_US -source-path+=g:\flexproj\locale\{locale}。這樣在g盤的flexproj目錄下建立一個locale目錄。
      然后目錄下放置包含我們要擴展的語言文件的文件夾就可以了。比如:g:\flexproj\locale\en_US。
      注意:locale下面的目錄名應(yīng)該和-locale=設(shè)置的名稱一致。
      那么這樣,我們就可以使用額外的語言設(shè)置了。

      舉個例子吧:
      查看項目屬性里Additional Compiler arguments配置為
      -locale+=en_US -source-path+=g:\flexproj\testgoufang\locale\{locale}
      然后在對應(yīng)的locale目錄下添加國際化資源文件,
      g:\flexproj\testgoufang\locale\en_US\strings.properties
      這一部分跟struts相似。
      里面的內(nèi)容為鍵=值的形式,如:
      Title=測試項目
      User=用戶名
      Password=密碼
      …………
      …………
      使用的時候可以通過[ResourceBundle]元數(shù)據(jù)標(biāo)簽來綁定locale文件,如:
      <mx:Metadata>
                                    [ResourceBundle("strings")]
      </mx:Metadata>
      即綁定上文提到的strings.properties文件,然后我們可以通過ResoueceManager來讀出其中的內(nèi)容,比如:
      var Title : String = resourceManager.getString("strings", 'Title');
      或者綁定到控件:
      [Bindable]
      private var Title:String;
      …………
      Title = resourceManager.getString("strings", 'Title');
      …………
      <mx:Label text="{Title}"/>
      如此多個項目共享統(tǒng)一資源

      如果編譯的時候沒有引用資源文件,則會報相應(yīng)的資源文件未找到。

      在build.xml中添加資源文件即可

      <source-path path-element="${project.dir}/locale/en_US"/>

      <source-path path-element="${project.dir}/locale/zh_CN"/>

      3.    編譯后的mx文件夾下所有圖片大小為0字節(jié)

      Mx中包括controls和container文件夾,主要包括用到的Flex控件的圖片,因此需要在source-path中指定圖片的位置,否則找不到圖片,大小就為0嘍;

      加入以下腳本即可:

      <source-path path-element="${projects.framework}/src"/>

      大概目錄位置是E:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\frameworks\projects\framework\src 里面包括一個mx文件夾,是Flex用到的所有資源圖片的存在位置。

      4. 工程目錄中包括mxml時編譯不到swc中

      因為我們編譯的時候首先是讀取src文件夾中的所有類,然后指定compc參數(shù)的include-classes參數(shù),這時只是指定的所有as文件,而mxml是不屬于某個包里面的,因此這里需要使用include-sources參數(shù)來指定。

      具體代碼如下:

          <include-sources dir = "${project.dir}\src\com\supermap\web\controls" includes = "Compass.mxml" />

      Build.xml文件內(nèi)容如下所示:

      <project name="Web.swc" basedir="." default="main" >

      <taskdef resource="flexTasks.tasks" classpath="E:\Flex\flexTasks\lib\flexTasks.jar" />

      <property name="FLEX_HOME" value="E:\Progra~1\Adobe\FlexBu~1\sdks\3.2.0" />  

      <property name="project.dir" value ="E:\FlexProject\FlexClient60\FlexClientLib" />

      <property name="output.file" value="Web.swc" />

      <property name="projects.framework" value="E:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\frameworks\projects\framework"/>

      <target name="main" depends="clean, log, compc" />

      <!-- deletes and recreates the compc directory -->

      <target name="clean">  

               <delete dir="${project.dir}\compile" failonerror="true"/>  

               <mkdir dir="${project.dir}\compile"/>

               <echo>${Root}\bin</echo>

      </target>

      <!-- runs the compc.exe compiler on the source -->

      <target name="compc">  

               <echo>${Root}/src</echo>

                         <fileset dir="${project.dir}\src" id="src.files">    

                                  <include name="**\**"/>    

                          </fileset>   
           
                         <!—遍歷src文件夾下的所有as文件-->

                         <pathconvert    

                           property="evaFramework_classes"    

                           pathsep=" "    

                           dirsep="."    

                           refid="src.files"    

                         >   
                                 <map from="\" to="/"/>    

                                  <map from="${project.dir}\src\" to=""/>    

                                  <mapper>    

                                        <chainedmapper>    

                                              <globmapper from="*.as" to="*"/>    

                                         </chainedmapper>    

                                  </mapper>    

                          </pathconvert>                  

                         <!--輸出所有類-->

                         <echo>${evaFramework_classes}</echo>

                         <!--開始編譯類庫文件-->

                         <compc output="${project.dir}\compile\${output.file}"    

                                   locale="en_US,zh_CN"   

                                   include-classes="${evaFramework_classes}"    

                                   optimize="true"

                                   benchmark="true"

                                  strict = "true"

                                  debug="true"

                                  as3="true"

                                  actionscript-file-encoding = "utf-8"

                                  allow-source-path-overlap = "true"

                                  use-resource-bundle-metadata = "true"

                       >                            
                                  <!--編譯源文件-->

                                  <source-path path-element="${project.dir}/src" />

      <!--如果類庫做了國際化,那么需要引入國際化資源文件,也就是工程目錄\locale\下面的所有資源文件(類型為.properties)-->

                                  <source-path path-element="${project.dir}/locale/en_US"/>

                                  <source-path path-element="${project.dir}/locale/zh_CN"/>
                                
      <!—需要指定引用圖片的資源文件,否則在編譯好的mx文件夾下的所有圖片都是0字節(jié)-->

                             <source-path path-element="${projects.framework}/src"/>

                                   <!-- List of SWC files or directories that contain SWC files. -->  

                                   <!—注意這里可以指定類庫文件的目錄啊,呵呵-->

                                   <compiler.include-libraries dir="${FLEX_HOME}" append="true">

                                           <include name="/frameworks"/>

                                   </compiler.include-libraries>

                  <compiler.include-libraries dir="${project.dir}" append="true">   

                      <include name="/lib" />   

                  </compiler.include-libraries>   

              </compc>   

      </target>  

      <!-- writes compc output to log file: compc-log.log -->

      <target name="log">  

               <record name="${project.dir}\compile\compc-log.log" action="start" append="true" />

      </target>

      </project>


      借鑒資源:

      http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html

      http://ericyou./blog/298336

      http://www./showdiary.jsp?id=219

      http:///questions/1400458/why-are-some-of-my-assets-0-byte-in-size-when-i-build-a-component-using-compc

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多