編程生活

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 瑞金市| 呼伦贝尔市| 长宁县| 那坡县| 绥江县| 西青区| 台南县| 贞丰县| 青浦区| 宝坻区| 公主岭市| 武邑县| 大埔县| 桑日县| 喀喇沁旗| 明光市| 桐柏县| 南丹县| 蓬莱市| 新化县| 钦州市| 抚州市| 宁阳县| 颍上县| 五寨县| 翁牛特旗| 咸阳市| 建湖县| 罗田县| 岑巩县| 临武县| 特克斯县| 牟定县| 寿光市| 临高县| 正镶白旗| 雷山县| 延庆县| 永定县| 开远市| 霍林郭勒市|