This is a piece of my code:
local function onComplete( event )
local photo = event.target
if photo then
print("Photo available")
else
--This is where I will swap the image of the imgMenu variable
--I tried removing the variable but it returns an "nil value" error
imgMenu:removeSelf()
imgMenu = display.newImageRect("image.jpg",system.ResourceDirectory,50,50)
imgMenu.anchorX=0
imgMenu.x =20
imgMenu.y=100
end
end
local function pickPhoto( event )
if media.hasSource( media.PhotoLibrary ) then
media.selectPhoto( { mediaSource=media.PhotoLibrary, listener=onComplete,destination = { baseDir=system.ResourceDirectory,filename=“image.jpg” } } )
else
txtnotice.text= “This device does not have a photo library.”
end
end
function scene:create( event )
local sceneGroup = self.view
imgMenu = display.newImageRect(“images/buttons/photo.jpg”,50,50)
imgMenu.anchorX=0
imgMenu.x =20
imgMenu.y = txttitleTab2.y + 50
imgMenu:addEventListener( "tap", pickPhoto )
sceneGroup:insert(imgMenu)
end