The following example shows how you can browse for a directory on the user’s computer in Adobe AIR by calling the browseForDirectory() method on a File object.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?> <!-- http://airexamples.com/2008/12/23/browsing-for-directories-on-a-users-computer-using-adobe-air/ --> <mx:WindowedApplication name="File_browseForDirectory_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Script> <![CDATA[ private var file:File; private function btn_click(evt:MouseEvent):void { file = new File(); file.addEventListener(Event.SELECT, file_select); file.browseForDirectory("Please select a directory..."); } private function file_select(evt:Event):void { lbl.text = file.nativePath; } ]]> </mx:Script> <mx:ApplicationControlBar dock="true"> <mx:Button id="btn" label="Click to browse" click="btn_click(event);" width="100%" /> </mx:ApplicationControlBar> <mx:Label id="lbl" /> </mx:WindowedApplication>
{ 3 comments… read them below or add one }
Hii,i want that whenever i do browseforOpen……whenever i get the dialog box for selecting files
,The label text field in name should get empty…..ne help
hii i want that the browse for directory box……should not give the browse for folder as title …ne idea
Nice work Peter,
This was of very help to me…