2 Replies Latest reply on Nov 5, 2010 9:32 AM by flexchief

    Ampersand url error

    flexchief Level 1

      Hi,

       

      I've made a simple mp3 player that plays tracks loaded from an xml file into a datagrid. Once the data is loaded into the datagrid the user can select a track and play it. Everything works fine until i try to play a track with '&' in its path.

       

      This causes the following error:

      Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.

       

      I assume this is because the URL appears incorrect to the player. If I simlpy remove the '&' and replace it with '&' the file plays fine?

       

      In my xml file, which is used to populate the datagrid, the location of each file is stored as well as various other information such as artist name, year, genre, path, etc. All '&' values in this xml file appear as '&'

       

      Is there any way to convert these values into a form that my player can read?

       

      Any ideas here would really help me out?

       

      Thanks

      Adam

      Flexchief

        • 1. Re: Ampersand url error
          Flex harUI Adobe Employee

          Try decodeURI or decodeURIComponent

          • 2. Re: Ampersand url error
            flexchief Level 1

            Thanks for the help flex harUI but sadly these did not work.

             

            I ended up parsing the string for char i didn't want (i.e. &) and removing it using the method below:

             

                        private function handleAmpersand(example:String, ac:ArrayCollection):void
                        {
                            //example = "It's a bird, it's a plane, it's ActionScript Man!";
                            var replaced:String = example; // Initialize replaced with the original text
                           
                            while ( replaced.indexOf( "&" ) != -1 )
                            {
                              replaced = replaced.replace( "&", "&" );
                            }
                           
                            ac.addItem(replaced);
                        }

             

            I hope this helps someone else out in the future?

             

            Flexchief