Flash
  Home arrow Flash arrow Page 5 - A Closer Look at Apollo`s File System API
IBM developerWorks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

A Closer Look at Apollo`s File System API
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-20

    Table of Contents:
  • A Closer Look at Apollo`s File System API
  • Copying and Moving Files and Directories
  • Reading and Writing Files
  • The open() and openAsync() Methods
  • File Open Modes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    A Closer Look at Apollo`s File System API - File Open Modes


    (Page 5 of 5 )

    The FileStream.open() method and FileStream.openAsync()method both accept two parameters: thefileparameter corresponding to the file that you want to open, and thefileModeparameter, which is a string defining the capabilities of theFileStreamobject. The possible values for thefileModeparameter are defined as constants in theFileModeclass.

    For example, the following code opens the file synchronously for write operations, but not for read operations:

      stream.open(file, FileMode.WRITE);

    Here are theFileModeconstants and their meanings:

    FileMode constant Definition
    FileMode.APPEND The file is opened in write-only mode, with all written data appended to the end of the file. Upon opening, any nonexistent file is created.
    FileMode.READ The file is opened in read-only mode. The file must exist (missing files are not created).
    FileMode.UPDATE The file is opened in read/write mode, and data can be written to any position in the file or appended to the end. Upon opening, any nonexistent file is created.
    FileMode.WRITE The file is opened in write-only mode. If the file does not exist, it will be created. If the file does exist, it will be overwritten.

      

    The FileStream class includes a number of read and write methods, each corresponding to the format of the data being read or written. For example, you can use the readUTFBytes()andwriteUTFBytes()methods to read or write an array of bytes, whereas thereadByte()andwriteByte()methods read or write a single byte at a time. All in all, there are 26 read and write methods. For details on each, see the description of these methods in the ActionScript 3.0 Language Reference, which is distributed with Apollo Alpha 1.

    Even though reading and writing text data may seem trivial, you should consider the encoding of the text in the file. ThereadUTFBytes()andwriteUTFBytes()methods provide means to read and write UTF-8–encoded text. ThereadMultiByte()andwriteMultiByte()methods let you specify a different character encoding for the file data. There are other factors to consider as well. For example, a UTF file may start with a UTF byte order mark (BOM) character, which defines the UTF encoding and the byte order (or “endianness”) of the data.

    For more information, see the “Data formats, and choosing the read and write methods to use” section of the Apollo Developer’s Guide (http://www.adobe.com/go/apollodocs).

    More Information

    For examples of reading and writing files, see the following sections in Chapter 5:


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Apollo for Adobe Flex Developer's Pocket...
     

    Buy this book now. This article is excerpted from chapter four of the Apollo for Adobe Flex Developer's Pocket Guide, written by Mike Chambers, Rob Dixon and Jeff Swartz (O'Reilly, 2007; ISBN: 0596513917). Check it out today at your favorite bookstore. Buy this book now.

    FLASH ARTICLES

    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders
    - Fun Things to Do with Movie Clips in Flash MX
    - Referencing Movie Clips in Flash MX







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway