4 Replies Latest reply on Apr 12, 2013 7:52 AM by nimitja

    AIR for iOS URL string problem

    andris_gauracs

      This is a very strange runtime error, that accurs on iOS devices but does not appear, when compiled on the AIR compiler

      I have an input text field movieSearch.pName.text, in which you can enter a value for a JSON URL search.

      On an iOS device it cannot load the URL request. when the text value is passed like this:

      var req:String = movieSearch.pName.text;

      var myRequest:URLRequest = new URLRequest('http://api.themoviedb.org/3/search/movie?query=%22+'+req+'+%22&api_key=****************');

       

      I have tried writing a value manually in the code, and this works fine:

       

      var myRequest:URLRequest = new URLRequest('http://api.themoviedb.org/3/search/movie?query=%22+matrix+%22&api_key=****************');

      or

       

      var req:String = "Matrix";

      var myRequest:URLRequest = new URLRequest('http://api.themoviedb.org/3/search/movie?query=%22+'+req+'+%22&api_key=****************');

       

      These 2 examples work, but the first example does not. Why is it so? Does anyone have a clue?

        • 1. Re: AIR for iOS URL string problem
          nimitja Adobe Employee

          Hi,

          Thank you for your issue report. If possible, could you please share the needed information like sample project, iOS device used with OS version, Adobe sdk version used. This would help us to investigate the problem.

           

          Regards,

          Nimit

          • 2. Re: AIR for iOS URL string problem
            andris_gauracs Level 1

            A sample project is something like this:

             

            import flash.data.*;

            import flash.text.*;

            import flash.display.*;

            import flash.events.*;

            import flash.net.*;

            import com.adobe.serialization.json.JSON;

             

             

             

             

            var movieSearch:TextField = new TextField();

            var resultField:TextField = new TextField();

            var searchButton:SimpleButton = new SimpleButton();

            addChild(movieSearch);

            addChild(resultField);

            addChild(searchButton);

            searchButton.addEventListener(MouseEvent.CLICK, simpleJSON);

             

             

            function simpleJSON(e:MouseEvent) {

                                var i:int;

                                var req:String = movieSearch.text;

                                var myRequest:URLRequest = new URLRequest('http://api.themoviedb.org/3/search/movie?query=%22+'+req+'+%22&api_key=******************* ******');

                                var myLoader = new URLLoader();

                                myLoader.addEventListener(Event.COMPLETE, onload);

                                myLoader.load(myRequest);

                                function onload(evt:Event):void {

                                          var myData:Object = JSON.parse(myLoader.data);

                                          var resultCount:int = myData.results.length;

                                          for (i=0; i < myData.results.length; i++) {

                                                    resultField.appendText(myData.results[i].original_title);

                                          }

                                }

            }

             

             

            I am using Flash Professional CS5.5 with AIR 3.2, and tested the compiled project on iPhone 4 with iOS 6.1

             

            The result field does not show anything on the device, but shows everything correcly in Flash.

            • 3. Re: AIR for iOS URL string problem
              andris_gauracs Level 1

              I found a solution:

              If the strings are divided into different variables and appended through the concat() function, it seems to work!

               

              var req:String = new String(movieSearch.text);

              var searchValue:String = "http://api.themoviedb.org/3/search/movie?query=%22+";

              searchValue = searchValue.concat(req,"+%22&api_key=*****************");

              var myRequest:URLRequest = new URLRequest(searchValue);

              • 4. Re: AIR for iOS URL string problem
                nimitja Adobe Employee

                Cool. Best of luck for your project.

                 

                Regards,

                Nimit