5 Replies Latest reply on Aug 10, 2011 4:06 AM by Balakrishnan V

    Flex Mobile : URLLoader bytesTotal always at 0 when loading file

    VinceDDH

      Hi !

       

      I'm trying to load external file with UrlLoader in a Flex Mobile Project ( Initialy it was with Data/Services Options of Flash Builder, but I have the same problem ). On the complete event, it work on the desktop ( bytesTotal, xml... ), but when i install my application on my nexus one ( air version : 2.5.0.1660 ), i've no data ( bytesTotal = 0 ), but the cache of the application has grown

       

      The application has these autorisations :

                  <uses-permission android:name="android.permission.INTERNET"/>
                  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
                  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

       

       

      If someone can help me...

       

      Thx !

       

      Vince

        • 1. Re: Flex Mobile : URLLoader bytesTotal always at 0 when loading file
          Mr Draust

          Did you find a solution for this?

           

          Ive got a very simular problem when i run a app on a device, it receieves no data.

          • 2. Re: Flex Mobile : URLLoader bytesTotal always at 0 when loading file
            Rangora Level 3

            Where is the file you try to load? I think you cannot access the private app install directory with the URLLoader.

            • 3. Re: Flex Mobile : URLLoader bytesTotal always at 0 when loading file
              Mr Draust Level 1

              Its an external file, located on a server.

               

              To be precise, im doing a post message to an obix server. Suppose to get back information/data in xml, but its not working.

              • 4. Re: Flex Mobile : URLLoader bytesTotal always at 0 when loading file
                irongamer

                After messing with the URLLoader for a native windows AIR app I gave up on it. That object will return 200, ok, complete, while failing to do what it says it did.

                 

                I never found any way to catch a real error from the server with any of the event listeners for URLLoader.  Instead I used HTTPService, it acutally returns useful data on server errors.  Here is an example, all this is tucked into my own class.

                 

                var service:HTTPService = new HTTPService();

                               service.url = url;

                               service.resultFormat = HTTPService.RESULT_FORMAT_E4X;

                               service.method = URLRequestMethod.POST;

                               service.addEventListener(ResultEvent.RESULT,serviceResult);

                               service.addEventListener(FaultEvent.FAULT,faultResult);

                               service.send(vars);

                 

                 

                 

                 

                private function serviceResult(eResult:ResultEvent):void

                          {              

                               var objResult:Object = eResult;              

                               if( objResult.result is XML )

                               {    

                                    xmlData = eResult.result as XML;

                                    trace(xmlData);

                                    dispatchEvent( new Event('eComplete') );

                               }

                               else

                               {

                                    //something wrong

                                    trace('BAD! No XML Returned: '+eResult.result);

                                    dispatchEvent( new Event('eError') );

                               }

                          }

                 

                         

                private function faultResult(e:Event):void

                          {              

                               if( e is ErrorEvent )

                               {

                                    trace( ErrorEvent(e).text );                   

                               }

                               else if ( e is FaultEvent )

                               {

                                    trace( FaultEvent(e).message.toString() );

                               }

                               else

                               {

                                    trace( 'Unhandled error' );

                               }

                              

                               dispatchEvent( new Event('eError') );

                          }