1 Reply Latest reply on Mar 7, 2009 12:28 PM by nemesis_256

    Trying to load MP3 from desktop to AIR application

    nemesis_256 Level 1
      I'm trying to load an MP3 file into an Air application. Here's some code. The first 2 lines are in my constructor

      fileToOpen.browseForOpen("Open", [new FileFilter("MP3", "*.mp3")]);
      fileToOpen.addEventListener(Event.SELECT, fileSelected);

      private function fileSelected(event:Event):void
      {
      var stream:FileStream = new FileStream();
      trace(fileToOpen.nativePath);
      // sound = new Sound(new URLRequest(fileToOpen.nativePath));
      // trace(sound);
      stream.open(event.target, FileMode.READ);
      trace(stream.bytesAvailable);
      sound = new Sound(stream.readBytes(stream.bytesAvailable));
      channel = sound.play(00000);
      addEventListener(Event.ENTER_FRAME, onEnterFrame);
      }

      Using URLRequest gives me the error Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error. I can't seem to load a file when I give it the full path. Then with the file stream, I don't even know what I'm doing. I don't know which method I'm supposed to use to load the file into a sound object. Please help...