Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Desktop, Mobile and non-browser Environments > AIR (Apollo)

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-06-2008, 07:56 PM   #1
shizny
Senior Member
 
Join Date: Jan 2003
Posts: 144
Default File Browse Box

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.

??
shizny is offline   Reply With Quote
Old 03-11-2008, 12:29 AM   #2
lucidmedia
Member
 
Join Date: Jun 2007
Location: Norton, MA
Posts: 57
Default

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);
}
lucidmedia is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 02:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.