Advertisement
br1wr2el3

App 06 - http

May 5th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1.  
  2. --# Main
  3. -- Appetizer 06 - http
  4.  
  5. -- Bruce Elliott
  6. -- May 2013
  7.  
  8. -- Use this function to perform your initial setup
  9. function setup()
  10. logoImage = nil
  11.  
  12. print("Touch the screen to see openURL() in action.")
  13. print("There does not appear to be a way to return")
  14. print("to your Codea program.")
  15.  
  16. print("http.request() has a parameter table.")
  17. print("I can not demonstrate that at this time.")
  18.  
  19. http.request("htt://weather.com/images/maps/current/curwx_720x486.jpg", didGetImage, failure)
  20. -- http.request("http://weather.com/images/maps/current/curwx_720x486.jpg", didGetImage, failure)
  21. end
  22.  
  23.  
  24. function failure(value1)
  25. print("fail")
  26. print(value1)
  27. end
  28.  
  29. function draw()
  30. background(53, 38, 38, 255)
  31. pushMatrix()
  32. spriteMode(CORNER)
  33. -- scale(2)
  34. if logoImage ~= nil then
  35. sprite(logoImage, 10,10,WIDTH)
  36. -- if value ~= nil then
  37. -- sprite(value, 10,98, WIDTH,HEIGHT)
  38. -- else
  39. -- ellipse(200,200,100)
  40. end
  41.  
  42. popMatrix()
  43. end
  44.  
  45.  
  46.  
  47. -- Our callback function
  48. function didGetImage( theImage, status, head )
  49. logoImage = theImage
  50. print(status)
  51. for k, v in pairs(head )do
  52. print(k.." "..v)
  53. end
  54. end
  55.  
  56. function touched (touch)
  57. openURL("http:/twolivesleft.com")
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement