ACE

Calendar

March 2007
S M T W T F S
  1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Tag Cloud

360Flex actionscript air android apple as3 books conference contest cookbook deeplinking FileReference flash flash builder flash catalyst flashplayer Flash Player flashplayer10 Flex flex4 flexbuilder flickr fotobooth Frameworks google gumbo ImageDropR indexing InsideRIA iphone java localconnection max merapi microsoft mobile pixel bender riatrax SilverLight sqlite swf Thermo update framework updatemanager URLTestr

Categories

Archives

Recent Posts

Recent Comments


« Editing the Apollo Descriptor File | Main | File and FileStream within Apollo - full source code »

Write your first file to the file system using Apollo

By Rich Tretola | March 19, 2007 Print This Post Print This Post
1,876 views

Creating a file is very simple with Apollo. This is a very basic example of how to create a new file which is saved to the appStorageDirectory. Simply create a new Apollo project within FlexBuilder and paste the following as the main file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version=â€1.0″ encoding=â€utf-8″?>
<mx:ApolloApplication xmlns:mx=â€http://www.adobe.com/2006/mxmlâ€>
<mx:Script>
<![CDATA[
import flash.filesystem.*;
private var stream:FileStream;
private function saveFile():void{
var file:File = File.appStorageDirectory.resolve("HelloWorld.txt");
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var str:String = "Congratulations on your 1st file, Rich Tretola - EverythingFlex.com";
stream.writeUTFBytes(str);
stream.close();
mx.controls.Alert.show("File has been saved to /n" + file.nativePath, "Notice");
}
]]>
</mx:Script>
<mx:Button label=â€Create File†click=â€saveFile()†/>
</mx:ApolloApplication>

Share this Post


Topics: Adobe AIR, Tutorials |

4 Responses to “Write your first file to the file system using Apollo”

Linda Rawson Says:
July 3rd, 2007 at 12:16 pm

Can you tell me what would be required from a user. Say a user worked at some computer security lockdown. What would the user need to run this application? For instance at most military installations they cannot run flash applications. Would they need flash to run this demo? Do they need admin privleges of any sort?

Linda Rawson
http://www.sensorytech.net

everythingflex Says:
July 3rd, 2007 at 12:19 pm

They would require the AIR runtime, which includes the Flash Player and allow the application to have local access to read and write to and from the file system.

jason vancleave Says:
July 8th, 2007 at 3:11 am

Thanks, very helpful

in Flex 3/AIR appStorageDirectory has been changed to applicationStorageDirectory

you also probably wanted “n” instead of /n for a new line.

jason vancleave Says:
July 8th, 2007 at 3:13 am

doh! comment form stripped out my backslash in the new line comment

Comments



You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser
Mobilytics