About

<#TEMPLATE_INCLUDE_NINEPAGE_ABOUTME#>
  • Jan

    7

    AIR 文件类型过滤

    • 0 Comments
    • Flash Platform
    • 发布:古树
    • 引用:0
    • 浏览:

    主要是browseForOpenMultiple第二个参数的使用,没啥好说的

    import flash.filesystem.*;
    import flash.events.FileListEvent;
    var docsDir:File = File.documentsDirectory;
    var _allFF:FileFilter = new FileFilter("*.bmp;*.jpeg;*.jpg;*.png","*.bmp;*.jpeg;*.jpg;*.png");
    var _bmpFF:FileFilter = new FileFilter("*.bmp","*.bmp");
    var _jpgFF:FileFilter = new FileFilter("*.jpg","*.jpg");
    var _jpegFF:FileFilter = new FileFilter("*.jpeg","*.jpeg");
    var _pngFF:FileFilter = new FileFilter("*.png","*.png");
    try {
     docsDir.browseForOpenMultiple("选择图像文件",[_allFF,_bmpFF,_jpgFF,_jpegFF,_pngFF]);
     docsDir.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
    } catch (error:Error) {
     trace(error.message);
    }
    function filesSelected(event:FileListEvent):void {
     for (var i:uint = 0; i < event.files.length; i++) {
      trace(event.files[i].nativePath);
     }
    }