3 Replies Latest reply on Sep 11, 2008 8:13 AM by charger

    How to read a file using flex???

    sri harsha namala Level 2
      Hi EveryOne,

      I want to read a text file using flex and wants to display that text in text Area , How to do this?
      Is there any way without using httpService ?Please let me know , Its very urgent for me.

      Thanks in advance.
        • 1. Re: How to read a file using flex???
          atta707 Level 2
          Flex runs inside a browser and as such can read files only from the server. No access to user's local files. To read a text file you're going to have to use HTTPService.

          If it's a desktop app, you might want to look into AIR that supports access to local file system.

          ATTA
          • 2. Re: How to read a file using flex???
            Level 7

            "atta707" <webforumsuser@macromedia.com> wrote in message
            news:gaac1h$gfj$1@forums.macromedia.com...
            > Flex runs inside a browser and as such can read files only from the
            > server. No
            > access to user's local files. To read a text file you're going to have to
            > use
            > HTTPService.

            You can also use HTTPRequest or URLLoader.


            • 3. Re: How to read a file using flex???
              charger
              Also...If you don't need the file to load at runtime, you can simply embed it:
              import mx.core.ByteArrayAsset;
              import flash.utils.ByteArray;
              [Bindable]
              [Embed(source="../assets/somefile.txt", mimeType="application/octet-stream")]
              private var somefileClass:Class;
              var somefileByteArray:ByteArrayAsset = ByteArrayAsset(new somefileClass());
              text_control.text=somefileByteArray.readUTFBytes(somefileByteArray.length);

              Only if you don't need to read it at runtime.

              M