Starting with build 2013.1043, on iOS, Android, Mac and Windows, we are rolling out new functionality within our network api. Network functions like download, request have been enhanced with new functionality. Check out our daily API docs under network and events under networkRequest here, to see how to do things like upload text files in a single call, view bytes transferred and more…

Also, please note that there are a few new functional changes that aren’t backwards compatible. As you can see in the code example below, event responses are now tables which include fileName and baseDirectory. Be careful to ensure that you treat event.response as a table now instead of a string

Here is a simple example of how to use the new event.response table information.

local function networkListener( event )
        if ( event.isError ) then
                print( "Network error - download failed" )
        elseif ( event.phase == "ended" )
                print( "displaying response image file" )
                myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 )
                myImage.alpha = 0
                transition.to( myImage, { alpha = 1.0 } )
        end
end
 
network.download(
        "http://developer.anscamobile.com/demo/hello.png",
        "GET",
        networkListener,
        "helloCopy.png",
        system.TemporaryDirectory
        )
  1. Thanks for the comments! It’s worth noting that we have extended the message support under Windows XP and we have resolved several small behavioral differences on iOS and Android in the latest daily build.

  2. Is it compatible with older versions of Android?
    I have tested successfully with Kindle (Android 2.3.4), but it fails with Android 2.3.5 (return status -1).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>