編程生活

             :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            113 隨筆 :: 0 文章 :: 18 評論 :: 0 Trackbacks

          To embed an arbitrary file, you declare a variable of type Class, and put [Embed] metadata on it, using the MIME type application/octet-stream. For example, you embed a text file like this:

          [Bindable]
          [Embed(source="Story.txt", mimeType="application/octet-stream")]
          private var storyClass:Class;

          The compiler autogenerates a subclass of the ByteArrayAsset class and sets your variable to be a reference to this autogenerated class. You can then use this class reference to create instances of the ByteArrayAsset using the new operator, and you can extract information from the byte array using methods of the ByteArray class:

          var storyByteArray:ByteArrayAsset = ByteArrayAsset(new storyClass());
          var story:String = storyByteArray.readUTFBytes(storyByteArray.length);

          posted on 2012-06-27 14:32 wilesun 閱讀(253) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 天津市| 江城| 南皮县| 南康市| 盐城市| 淮北市| 筠连县| 寻甸| 和顺县| 张家口市| 佛山市| 察雅县| 台安县| 枣强县| 富裕县| 太谷县| 台北县| 广安市| 贵港市| 兴国县| 集贤县| 芒康县| 桐柏县| 江都市| 商洛市| 平和县| 西贡区| 博罗县| 湾仔区| 秭归县| 大厂| 威信县| 海宁市| 思南县| 巴彦淖尔市| 佛山市| 雷山县| 绵竹市| 施甸县| 会理县| 乌苏市|