我必须使用 flex 读取文件夹中的文件名。但是我在代码中遇到了一些错误。文件未定义。以下代码是:
protected function myCBSelectedXMLs_changeHandler(event:IndexChangeEvent):void
{
try
{
var fileName:String = new String();
if(myCBSelectedXMLs.selectedIndex == spark.components.ComboBox.CUSTOM_SELECTED_ITEM)
myCBSelectedXMLs.dataProvider.addItem(myCBSelectedXMLs.selectedItem);
Alert.show(myCBSelectedXMLs.selectedItem +" is selected", "Selection", Alert.OK);
var dir : File = File.desktopDirectory.resolvePath("MyFolder");
dir.getDirectoryListingAsync();
dir.addEventListener(FileListEvent.DIRECTORY_LISTING,onDirectoryListComplete);
}
catch(error:Error)
{
Alert.show("error", "Selection", Alert.OK);
}
}