I am including the whole code I created to test for the problem. it is not too long.
main.lua:
[lua]local storyboard = require( “storyboard” )
display.setStatusBar(display.HiddenStatusBar)
storyboard.gotoScene( “addimg”)[/lua]
addimg.lua:
[lua]local widget = require “widget”
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local _X = display.viewableContentWidth; _Y = display.viewableContentHeight
local saveBtn, image
local function onSaveBtnRelease()
storyboard.removeScene(“addphoto”)
storyboard.gotoScene(“addphoto”, “fromRight”)
end
function scene:createScene( event )
addimgGroup = self.view
saveBtn = widget.newButton{
defaultFile=“Save.png”,
overFile=“Saveovr.png”,
width=120, height=120,
onRelease = onSaveBtnRelease – event listener function
}
saveBtn.x =_X * 0.5
saveBtn.y = _Y * 0.5
saveBtn.isVisible = false
addimgGroup:insert(saveBtn)
image = display.newImageRect(“maze01.jpg”, 400, 300)
image.isVisible = false
addimgGroup:insert(saveBtn)
end
function scene:enterScene( event )
saveBtn.isVisible = true
image.isVisible = true
addimgGroup:insert(saveBtn)
local i = 3
display.save( image,“myImage”…i…".jpg", system.DocumentsDirectory )
end
function scene:exitScene( event )
display.remove (saveBtn)
display.remove (image)
saveBtn = nil
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene )
end
function scene:destroyScene( event )
display.remove (saveBtn)
display.remove (image)
saveBtn = nil
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene)
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene[/lua]
addphoto.lua:
[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
function scene:createScene( event )
addphotoGroup = self.view
local i =3
local imagePath = system.pathForFile( “myImage”…i…".jpg", system.DocumentsDirectory )
local image = display.newImageRect(imagePath, 864, 648)
image.isVisible = false
addphotoGroup:insert(image)
end
function scene:enterScene( event )
image.isVisible = true
end
function scene:exitScene( event )
display.remove (image)
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene )
end
function scene:destroyScene( event )
display.remove (image)
image = nil
scene:removeEventListener( “createScene”, scene )
scene:removeEventListener( “enterScene”, scene )
scene:removeEventListener( “exitScene”, scene )
scene:removeEventListener( “destroyScene”, scene)
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene[/lua]
Thank you.