Flex 创建过滤特定文件的FileReference

1.var imagesFilter:FileFilter = new FileFilter("Images","*.jpg;*.gif;*.png");  
2.var docFilter:FileFilter = new FileFilter("Documents","*.pdf;*.doc;*.txt");  
3.var myFileReference:FileReference = new FileReference();  
4.myFileReference.browse([imagesFilter, docFilter]); 



1.<?xml version="1.0"?>  
2.<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">  
3.  <mx:Script>  
4.    <![CDATA[  
5.      private var oneFileFileFilter:FileFilter = newFileFilter("sample.pdf", "sample.pdf");  
6.      private var pdfFileFileFilter:FileFilter = newFileFilter("PDF Files", "*.pdf");  
7.      private function oneFile():void{  
8.        var fileRef:FileReference = new FileReference();  
9.        fileRef.browse([oneFileFileFilter]);  
10.      }  
11.      private function pdfFiles():void{  
12.        var fileRef:FileReference = new FileReference();  
13.        fileRef.browse([pdfFileFileFilter]);  
14.      }  
15.    ]]>  
16.  </mx:Script>  
17.  <mx:Button label="One File - sample.pdf"click="oneFile()"/>  
18.  <mx:Button label="All pdf Files" click="pdfFiles()"/>  
19.</mx:Application> 

你可能感兴趣的:(Flex 创建过滤特定文件的FileReference)