I had a situation today where another developer needed to know how to determine how many lines were in a text file with AIR. Especially for developers that are not used to working with binary data - this could prove difficult. Making a solution that worked consistently across multiple platforms would be even more challenging as some OS's use different 'end line' characters. However, this is another area where AIR helps you out.
The File Class's Static Properties
If you want to work with the user's local filesystem at all, you will be using instances of the File class. This class also provides static properties that help you create consistent experiences across multiple operating systems. For example, there are several properties that map to specific directories on a user's computer (documentsDirectory will map correctly whether you are on Mac or PC). In addition, there is a property File.separator which displays the current path separator (so you don't have to worry if it is '/' or '\'). For our example today, we will be using File.lineEnding which will correspond to the correct line ending characters for your platform.
Once we have this is place, we can easily determine the number of lines in a text file by following these steps:
File.lineEnding property into an Array.In the following example, those items are accomplished. This is a Flex-based AIR application, but it could easily be modified to work with Flash.
[...] http://www.davidtucker.net/2008/08/22/air-tip-13-number-of-lines-in-a-text-file/ [...]