3 Replies Latest reply on Jul 31, 2013 5:53 PM by Ned Murphy

    URLRequest error external sound

    asydd Level 1

      Hi All: AS3 AIR 3.7 for iOS Flash CC Mac OS

      Yesterday I had a Flash CC project that loaded and played external sound files.

       

      package  {

        import flash.display.MovieClip;

        import flash.filesystem.File;

        import flash.media.Sound;

        import flash.media.SoundChannel;

        public class soundiOS extends MovieClip {

            public function soundiOS() {

               var sFile:File = File.applicationDirectory.resolvePath("sndf/loadWeb.mp3");

               var channel:SoundChannel = new SoundChannel();

               var snd_1:Sound;

               if (sFile.exists) {

                  trace('File FOUND: ');

                  snd_1 = new Sound();

                  snd_1.load(new URLRequest(sFile.url));                   // line 23

               } else {

                  trace('File NOT found: ');

                  snd_1 = new p0spop();

               }

                  channel.stop();

                  channel = snd_1.play();

       

                            } // soundiOS

                } // class

      } //package

       

      Today when I went to test I got ~ soundiOS.as, Line 23, Column 20 1180: Call to a possibly undefined method URLRequest.

      If I remove the if (sFile.exists) the library based sound plays from the Class AS file.

      If I put the same coding into the FLA direct without a linked Class AS file and test the file, works fine.

      The moment I link a Class file to it, even with an empty constructor function and the previously working code in the FLA file - it throws the above error.

      If I open the file(s) in Flash CS6 same scenario. Have placed the sound code (only) from the project to a new file to eliminate other items and same result.

      Thanks.