i make music player and use FileFilter for filter mp3 and .. files .
this is my code :
<![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]);
}
error in this line :
file.browseForDirectory("Open",[filter]);
1137: Incorrect number of arguments. Expected no more than 1.
thank you
The error clearly says what's wrong. You always can open a documentation related to your code and check the required arguments: Adobe File class documentation
In your case you must remove the second argument:
file.browseForDirectory("Open"); // assuming that Open is a dirname
If you want to use FileFilter, then use other method:
file.browseForOpen("Open",[filter]);