Thursday, March 10, 2011

Introduction to Adobe AIR: Part 9

Today we will learn about absolute paths.

If needed, you can refer to files and directories by specifying absolute paths to them. You can do that when defining a file object:

import flash.filesystem.File;

var exampleDirectory:File = new File("C:/Documents and Settings/Usernamehere/My Documents/Air Examples/");

As you can see, I have used the / slash separator in the example above. Unlike the resolvePath() method, the File constructor allows us to use both / and \ separators. However, if you use \, you'll need to double them (because the \ symbol is reserved and to pass it as a text value you need to neutralize it first).

var exampleDirectory:File = new File("C:\\Documents and Settings\\Usernamehere\\My Documents\\Air Examples\\");

If you need to return an absolute path to a file, use the nativePath property of the File class. For example, to see the absolute path to the user's documents directory, use it like this:

var exampleDocumentsPath:String = File.documentsDirectory.nativePath;

The result will be something like this (I'm running Windows):

C:\Users\7 User\Documents

Here's another example of using nativePath, this time on a File class that we have created using resolvePath first:

var exampleText:File = File.documentsDirectory.resolvePath("Air Examples/text.txt");

And the output is:

C:\Users\7 User\Documents\Air Examples\text.txt

Thanks for reading!


Introduction to Adobe AIR: Part 1
Introduction to Adobe AIR: Part 2
Introduction to Adobe AIR: Part 3
Introduction to Adobe AIR: Part 4
Introduction to Adobe AIR: Part 5
Introduction to Adobe AIR: Part 6
Introduction to Adobe AIR: Part 7
Introduction to Adobe AIR: Part 8


electronic signature software said...

From the theme you used I guess that your website is made using drupal but how that can be done on blogspot.Can you please tell me how you used this layout?Thanks in advance.

Kirill Poletaev said...

Nope, I didn't use anything like Drupal. I just downloaded a free blogger theme from some template site, then modified it a lot using HTML and CSS.

In fact, I am mostly negative about these Drupal/Joomla/etc CMS services... I am not really satisfied with the way Blogger handles some things too (lots of errors if you run a check), but oh well.

Post a Comment