| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Senior Member
Join Date: Jan 2003
Posts: 144
|
Does anybody have an example of how to create a file browse dialog box that will open (xml file) the selected file in the AIR app. I've been looking, but everything I see has to do with selecting a file and uploading it. I want to select a file and open it.
?? |
|
|
|
|
|
#2 |
|
Member
Join Date: Jun 2007
Location: Norton, MA
Posts: 57
|
you are looking for "browseForOpen". This will open a native file dialog and, when the user selects a file, returns an event with the native path.
the code below is fragmentary, but should give a sense of how you pull in a string and cast it to an XML object. private var _data:String; private var _dataXML:XML; private var fileToOpen:File; function selectTextFile(root:File):void { var txtFilter:FileFilter = new FileFilter("Text", "*.as;*.css;*.html;*.txt;*.xml"); // file filter object tells open dialog what is selectable root.browseForOpen("Open a Semester to Edit", [txtFilter]); // open the file root.addEventListener(Event.SELECT, fileSelected); // event for when user selects a file } function fileSelected(event:Event):void { var stream:FileStream = new FileStream(); // open filestream stream.open(fileToOpen, FileMode.READ); // open the file _data = stream.readUTFBytes(stream.bytesAvailable); // read file stream.close(); // close file _dataXML = XML(_data); // cast the string to XML trace(_dataXML); } |
|
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| load text file into scroll box | edudmnik | ActionScript 2.0 | 4 | 01-04-2008 09:27 PM |
| how to load a varible xml file based on user select box? | scheinarts | ActionScript 2.0 | 3 | 07-27-2007 08:39 PM |
| Upload file from local PC to Server | Brandon Rohde | ActionScript 2.0 | 3 | 12-01-2005 04:11 PM |
| File browse button? | Dauntless | Other Flash General Questions | 4 | 11-09-2004 11:55 AM |
| Open file -- Browse bouton | Batmel | ActionScript 2.0 | 2 | 08-27-2004 04:30 PM |