Want to place button on top of image after download via http

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]

Perhaps
button1:toFront()

http://docs.coronalabs.com/api/type/DisplayObject/toFront.html

Best regards
[import]uid: 6666 topic_id: 32342 reply_id: 128750[/import]

Thanks, but no go. Had tried that already :slight_smile:

Tried with a delay too.
Must just not have the correct place for the toFront() code yet.

Edit:
GOT IT… I think.
I put button1 and testImage into a group and now the button1:toFront() works.
Off to try it in my actual App.
[import]uid: 6547 topic_id: 32342 reply_id: 128768[/import]

Perhaps
button1:toFront()

http://docs.coronalabs.com/api/type/DisplayObject/toFront.html

Best regards
[import]uid: 6666 topic_id: 32342 reply_id: 128750[/import]

Thanks, but no go. Had tried that already :slight_smile:

Tried with a delay too.
Must just not have the correct place for the toFront() code yet.

Edit:
GOT IT… I think.
I put button1 and testImage into a group and now the button1:toFront() works.
Off to try it in my actual App.
[import]uid: 6547 topic_id: 32342 reply_id: 128768[/import]