編程生活

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

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


          網站導航:
           
          主站蜘蛛池模板: 大渡口区| 唐海县| 金门县| 广饶县| 武穴市| 三穗县| 祥云县| 河源市| 个旧市| 通城县| 横峰县| 酉阳| 罗平县| 南华县| 衡水市| 屯昌县| 宿迁市| 永寿县| 乡宁县| 全椒县| 宣威市| 米泉市| 克东县| 万宁市| 榕江县| 静海县| 朝阳县| 新巴尔虎右旗| 桐庐县| 瓦房店市| 饶河县| 太仓市| 四平市| 宁南县| 宜丰县| 杭锦旗| 克拉玛依市| 惠水县| 浦江县| 堆龙德庆县| 商丘市|