Solved

Path to file for AIR

Posted on 2008-10-13
5
548 Views
Last Modified: 2013-11-11
I'm creating an air file.  Is there a way to get the path that the air file resides at?  Something similar to file.nativePath, but instead of giving the path of a file, I want the path of my air exe/app,
0
Comment
Question by:walker6o9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Savong
ID: 22707604
The applicationDirectory property of any File object should give you this value.
0
 
LVL 1

Author Comment

by:walker6o9
ID: 22707657
I got the following error.

My relevant code below.  I imported the filesystem class and declared file as a file object earlier in code but don't want to include it so as not to clutter things up too much for you.


MY ERROR:


ReferenceError: Error #1069: Property applicationDirectory not found on flash.filesystem.File and there is no default value.
      at XBoxApp/showCompleteScreen()[C:\Users\freelance9\Desktop\Interfaces\Design\XBoxApp.as:363]
      at XBoxApp/onDownloaded()[C:\Users\freelance9\Desktop\Interfaces\Design\XBoxApp.as:533]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/onComplete()
public function startDownload( evt:Event )
		{
			this.hideDownloadscreens(evt);
		
			file.addEventListener( Event.SELECT, dirSelected );
			file.browseForDirectory( "Select a directory" );
		}
		
		//--------------------------------------------------------------------------------
		// Open a directory selection window
		public function dirSelected( evt:Event )
		{
			if ( this.fileList.length > 0 )
			{
				this.currentFile = 0;
				driveNum = 0;
				var drive:String = "";
				this.loadFile(drive);
			}
		}
		
 
 
public function loadFile(drive:String):void
		{
			
			
			var filename2:String = this.fileList[this.currentFile];
			var byteLoader:URLLoader = new URLLoader();
		
			byteLoader.dataFormat = URLLoaderDataFormat.BINARY;
			byteLoader.addEventListener( Event.COMPLETE, onDownloaded );
			byteLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler );
			byteLoader.addEventListener( HTTPStatusEvent.HTTP_STATUS, httpStatusHandler );
			byteLoader.addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler );
		
			var filename:String = new String();
			filename = drive + filename2;
			
			//filename = filename2;
			
			var fileRequest = new URLRequest( filename );
		
			
			trace("DIRECTORY: "+file.applicationDirectory);
			byteLoader.load( fileRequest );
			
			
		}
		

Open in new window

0
 
LVL 10

Expert Comment

by:Savong
ID: 22708150
Well, it looks like applicationDirectory is a static property so it can be accessed like so:
File.applicationDirectory.nativePath

More info is here:
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html#applicationDirectory
0
 
LVL 1

Author Comment

by:walker6o9
ID: 22717192
I tried that, but it gives me the path to the storage or app directories that are created in air.

Basically, I have the air files running on DVD's, and what I need to get the drive name that the DVD is in.  So far example, for most cases, this would be a D on an E.  
0
 
LVL 10

Accepted Solution

by:
Savong earned 500 total points
ID: 22718199
AIR files can't run from a DVD so they won't have a reference to that location.  The file only "runs" from the installed files.  Your only real option for getting a location on the DVD would be to ask the user to browse, or guess a path and test for files that you expect.  There's not many provisions in AIR (at least currently) for working from optical media.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Link puzzle piece images together and change color on hover 2 458
How to display a webpage in a flash 10 384
Embedded Video Download (Flash) 3 1,196
Adobe Flash player - Microsoft Edge 9 184
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question