My app looks up part numbers and each part number may have 1 - 4 images associated with it.
I’m experimenting with the Simple Image Download in the Samples.
I want to display arrow images over top of the image and then when the arrow is touched I load another image.
In the modified Simple Image Example the button still works even though the image is on top of it but doesn’t make it very intuitive.
How can I modify this code to have button1 show on top of the image, I.e. make it visible.
[code]
– Load the relevant LuaSocket modules (no additional files required for these)
local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local widget = require(“widget”)
tmastimages = {“25307.png”,“58152a.png”,“15309.png”}
k = 0
– Comes here after starting the HTTP image load
function showImage(k)
print("showimage tmastimages: "…k,tmastimages[k])
– We need to turn off the Activity Indicator in a different chunk
native.setActivityIndicator( false )
– Normally we would io.close(myFile) but ltn12.sink.file does this for us.
– Display local file
testImage = display.newImage(tmastimages[k],system.DocumentsDirectory,10,100);
–>
–> after each image is displayed I want to make the button visible over top of the image.
–>
end
– Load the image from the network
– Turn on the Activity Indicator showing download
function loadImage()
k = k + 1
if k > #tmastimages then k = 1 end
print(“tmastimages:”,k,tmastimages[k])
– Create local file for saving data
local path = system.pathForFile( tmastimages[k], system.DocumentsDirectory )
local myFile = io.open( path, “w+b” )
native.setActivityIndicator( true ) – show busy
– Request remote file and save data to local file
http.request{
url = “http://shop.rareparts.com/png/png300/”…tmastimages[k],
sink = ltn12.sink.file(myFile),
}
– Call the showImage function after a short time dealy
timer.performWithDelay( 400, showImage(k))
end
– Add demo button to screen
button1 = widget.newButton{
default = “btn.png”,
over = “btnA.png”,
onRelease = loadImage
}
button1.x = 160
button1.y = 380
– Add label for button
b1text = display.newText( “Click To Load”, 0, 0, nil, 15 )
b1text:setTextColor( 45, 45, 45, 255 ); b1text.x = 160; b1text.y = 380
– Displays App title
title = display.newText( “Simple Image Download”, 0, 30, native.systemFontBold, 20 )
title.x = display.contentWidth/2 – center title
title:setTextColor( 255,255,0 )
[/code] [import]uid: 6547 topic_id: 32342 reply_id: 332342[/import]
