編程生活

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            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 閱讀(251) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 秀山| 丹江口市| 闵行区| 汤阴县| 台中市| 金溪县| 蓬安县| 当雄县| 铜梁县| 建水县| 廉江市| 马鞍山市| 锦州市| 阿尔山市| 从江县| 靖江市| 高尔夫| 湟源县| 宿州市| 蓬溪县| 鄯善县| 门头沟区| 无棣县| 德钦县| 阿坝| 灯塔市| 青田县| 沂源县| 湖南省| 公安县| 兴业县| 噶尔县| 万全县| 壶关县| 营口市| 西城区| 类乌齐县| 成武县| 林口县| 普兰店市| 隆尧县|