apache-flex AS3 Flash Builder错误:参数数目不正确

dwthyt8l  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(152)

我制作音乐播放器,并使用FileFilter过滤mp3和..文件。
这是我代码:

  1. <![CDATA[
  2. import flash.events.IOErrorEvent;
  3. import flash.events.ProgressEvent;
  4. import flash.media.Sound;
  5. import flash.media.SoundChannel;
  6. import flash.media.SoundTransform;
  7. import flash.net.URLRequest;
  8. private var sound:Sound;
  9. private var songLength:String;
  10. private var soundChannel:SoundChannel;
  11. [Bindable]
  12. private var readyToPlay:Boolean = false;
  13. [Bindable]
  14. private var playing:Boolean = false;
  15. private var file:File;
  16. private var filter:FileFilter = new FileFilter("Music", "*.mp3;*.ogg");
  17. protected function browse_clickHandler(event:MouseEvent):void {
  18. file = new File();
  19. file.addEventListener(Event.SELECT, onFileSelect);
  20. file.browseForDirectory("Open",[filter]);
  21. }

此行中错误:
“打开”,[过滤器];
1137:参数数目不正确。应该不超过1个。
谢谢你

u3r8eeie

u3r8eeie1#

错误会清楚地指出错误所在。您可以随时打开与代码相关的文档并检查所需的参数:Adobe文件类文档
在您的情况下,您必须移除第二个参数:

  1. file.browseForDirectory("Open"); // assuming that Open is a dirname

如果要使用FileFilter,则使用其他方法:

  1. file.browseForOpen("Open",[filter]);

相关问题