Advertisement
reshetnikoff

Untitled

Jul 21st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | None | 0 0
  1.  
  2.    
  3.  
  4.    
  5.  
  6.      
  7.         for i = 1,5 do
  8.  
  9.  
  10.             local function networkListener( event, urlOfImage )
  11.                 if ( event.isError ) then
  12.                     print( "Network error - download failed: ", event.response )
  13.                 elseif ( event.phase == "began" ) then
  14.                     print( "Progress Phase: began" )
  15.                 elseif ( event.phase == "ended" ) then
  16.                     print( "Displaying response image file" )
  17.                     -- myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 )
  18.                        
  19.                     imageContent = display.newImageRect(contentGroup, event.response.filename,event.response.baseDirectory, 100, 100);
  20.                     imageContent.x = -display.contentWidth/3
  21.                     imageContent.y = 5+(110+10)*(i-1)
  22.  
  23.                     contentGroup.x = display.contentCenterX
  24.                     -- contentGroup.y = (110+10)*(i-1)
  25.                     scrollView:insert(contentGroup)
  26.  
  27.                
  28.  
  29.                 end
  30.             end
  31.  
  32.  
  33.             local contentGroup = display.newGroup()
  34.            
  35.             local backgrRect = display.newRect(contentGroup, 0, 5, display.contentWidth, 110 ):setFillColor(0.4)
  36.  
  37.             local textTitle = jsonData[i].name
  38.             local textTitleObject = display.newText(contentGroup, textTitle, 110, -20, 300, 50, "Helvetica", 20)
  39.  
  40.             local textDescr = jsonData[i].description
  41.             local textDecsrObject = display.newText(contentGroup, textDescr, 60, 25, 200, 50, "Helvetica", 14)
  42.            
  43.  
  44.  
  45.            
  46.  
  47.             local params = {}
  48.             params.progress = true
  49.             local urlOfImage = jsonData[i].img
  50.  
  51.             -- local urlOfImage = "http://docs.coronalabs.com/images/simulator/image-mask-base2.png"
  52.  
  53.             print(urlOfImage)
  54.             print("check")
  55.  
  56.             contentGroup.x = display.contentCenterX
  57.             contentGroup.y = (110+10)*(i-1)
  58.             scrollView:insert(contentGroup)
  59.  
  60.  
  61.  
  62.             params =
  63.             {
  64.             }
  65.  
  66.             params[i] = urlOfImage
  67.             print("Param"..i,"=",params[i])
  68.  
  69.             network.download(
  70.                 urlOfImage,
  71.                 "GET",
  72.                 networkListener,
  73.                 params,
  74.                 "helloCopy.png",
  75.                 system.DocumentsDirectory
  76.             )
  77.  
  78.  
  79.                 -- local imageContent = display.newImageRect(contentGroup, "img/img1.jpg", 100, 100);
  80.                 -- imageContent.x = -display.contentWidth/3
  81.                 -- imageContent.y = 5
  82.  
  83.  
  84.            
  85.  
  86.  
  87.            
  88.  
  89.             local options =
  90.             {
  91.                 effect = "fade",
  92.                 time = 400,
  93.                 params = {
  94.                     iCount = i,
  95.                     textT = textTitle,
  96.                     descrD = textDescr
  97.                 }
  98.             }
  99.  
  100.             contentGroup:addEventListener("tap",    
  101.  
  102.             function(event)
  103.                 -- composer.showOverlay("scenes.activity")
  104.                 -- composer.gotoScene("scenes.activity", options)
  105.  
  106.  
  107.                 print("hello")
  108.             end
  109.             );
  110.            
  111.  
  112.            
  113.         end
  114.  
  115.  
  116.  
  117.  
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement