AS3 Flash Builder错误参数数量不正确

时间:2017-01-03 09:16:59

标签: actionscript-3 flash flex air flash-builder

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

<![CDATA[
            import flash.events.IOErrorEvent;
            import flash.events.ProgressEvent;
            import flash.media.Sound;
            import flash.media.SoundChannel;
            import flash.media.SoundTransform;
            import flash.net.URLRequest;

            private var sound:Sound;
            private var songLength:String;
            private var soundChannel:SoundChannel;
            [Bindable]
            private var readyToPlay:Boolean = false;
            [Bindable]
            private var playing:Boolean = false;
            private var file:File;
            private var filter:FileFilter = new FileFilter("Music", "*.mp3;*.ogg");

            protected function browse_clickHandler(event:MouseEvent):void {
                file = new File();
                file.addEventListener(Event.SELECT, onFileSelect);
                file.browseForDirectory("Open",[filter]);
            }

错误在这一行:

file.browseForDirectory( “打开”,[过滤]);

  

1137:参数数量不正确。预计不超过1个。

谢谢

1 个答案:

答案 0 :(得分:1)

错误清楚地说明了什么是错的。您始终可以打开与您的代码相关的文档并检查所需的参数:Adobe File class documentation

在您的情况下,您必须删除第二个参数:

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

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

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