Apollo Alpha Preview – Using the Apollo File API

(My Original Blog Post: -*http://api-madness.com/post/apollo-alpha-preview-using-the-apollo-file-api/)

Attention! API Garbage (might be unreadable):

fall file save

Application was built with simple HTML editor which will highlight some future APIs Apollo provides 300 and so create a new Apollo Project with the Fox bowlers from the foul new Apollo Project and begin through basic project and let s call this HTML editor will use the default location this click finish this will create all the default false for me just as we did in whole world we need to go to edit a few properties and the XML file and hit enter their affiliatescall was calm about my chambers but HTML editor in list is look over other properties so named HTML editor given a description of simple issue motive or and we do know the publisher which is me my chambers or signature owning and assorted rude constant tide of which can just use a rigorous system chrome server thing here is falling will come back later and add the icons will fill that in just just also say this fall file and save what we can close that in the switchover time XML file is the default application that looks to close which overthrew the design view so can actually lay out the UI of our petition to force a larger owner bring a button_click of the components panel and drag it over bringing the corner and with that select them will come over the properties panel will give it an ID first one is called save button and basically the IDE is giving the component of variable names so you can reference it later on within your application also change the label will call it saved them if only one scroll down to the constraint options and we want this button always be in the bottom right panel source, thank you then write their own right you can see here for and hit enter up your solicitor for now this button over the long right the next thing we need is a go back over her components you can select a text input this just a simple text field and displace RMS a save button again with that select to go to the properties of you forgive the ID of file name will use this solo all the user to put in the file name and the default text with go ahead and give it a default value just so we ll have the full limit recounts one scallop test.html for traditional fall and again we want to set the constraint options again we just want the text input to be in this position along the bottom phones, select this on the bottom to get to the bottom and then to the right and you can see here is about 72 pixels there and that s just where we are dragged final thing we need to do is bring enough text area control so drag the text area control from the components you onto the stage and the Marina resizes to take up most of the stage and this is control that shouldn t be used actually type in the HTML photo with the control selected again go to flex properties when given the ID modems call this input field and then we want to go down to the constraint properties and we wanted to take up the space of Corsica so just tag it on all four corners and basically this ll save these dimensions will always say the same as we resize to this point we can save the file to the file and save him and we can test the supplication Infosys run that need to see everything ran safe resizing works so resizing works correctly and can type in my text area so we can close out so our UIs also solus switchover to the source you and now we need to add some action script code is with action script total dues Watson code so when the user presses the save button will actually write the fall out to the fall system so I want to add a new M. XML tag in this election script tag and you could see him getting code completions that AMEX: script of that and UC Fox bowlers give me code completion and writing some of the XML forming in the first thing I want to do is come down to the save button which is right here the button tag and we will not listen for the click event and basically when the user presses could lead we want to tell the button what code to call forward ~call function called on click and now we need to create a function so you can move back up to the script block and create an action script function Pvt. function on click and this is just basic action script three if you can do to flex her nude action script make sure to check out some of the introductory flex movies also on London.com so now created a function of this functional get called every time that the user presses the save button normally do when they presses button will write the text out to the file system for Xanadu just made a little easier will just hardcode that the fall of always get saved to the desktop. And so the desktop and we can do that using the new fall API you can see Fox bowlers give me some code completion if it didn t code complete for you then you can just type in import flash.fall system of file and must just import the class and we want to use a static API called desktop directory and missile return a reference to the default directory next we want to actually create the file on the directory through Iraq should create a new file called save fall again at the file in now would it create this on the desktop directory through Josxe9 desktop but resolved no resolve the debate beyond the fall API that basically puts together to pass from this case we want to add the file name that the user specifies overlook down here again we have the tech simple or they can specify the file name and so we just want to grab that once a fall name.txt and all that s going to do is describe the file name and then create off on the desktop of course it having created the fall yet we haven t opened it yet and we written treatise of us what we need to do next order to actually write to the fall we want to fall stream object and UC flex builder again has given me code completion is automatically important for me to import flash.fall system of fall stream resource a new fall stream and then we will open it and knows what the open call actually does business as when it actually opens up the fall if it hadn t been created or created at this point and open up the right of it so takes two arguments the first one is the fault open to and that s our same file and then the second is a stream which you can get from a class called file mode and you make sure to import file modes with import flash.fall system of fall mode and you should get code completion and we wanted to fall mode.write is what that ll do that will get the falls this ll overwrite the file and the file doesn t exist it will create a fun-loving wonder that you write to the fall we will write what the user typed into the text field for the fall so we ll say also summer of thousands of a variable name and the user API and actually can see here her a lot of API different ways you can write files through Josxe9 Wright UTS bites this allows us to write a fall in a UTF-8 encoding them in one pass in a string to write in that begin returning from our text area which is called input field solicited input field.txt and then finally we would does one make sure we close it so a close of the fall of go of it and that s all we have so let s save this and we save a flexible actually compile it and if we made any typos or errors that ll told some problems easier we make any errors now we can test this morning that Ron feel my text area here domination mother selecting the type of racing no body tag and was put arose simple drag here is a very basic additional document entering at the station always do that sort click save and L3 switch to a desktop and click right here you can see we have test out a Chanel fall double-click the open of Safari and we have our simple HMO fall so those are two pretty simple but only took a couple lines of code you can of course read and write files but pretty much no matter what you re doing you re going to follow the same steps which is located to fall your right open the fall stream object and rewrite the file and close it so the next step will be that of live preview of the HML as we type it and will do that in the next


~ by bitahatini on December 18, 2008.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: