Hello guys ,
I am getting this error again and again when i am going to hide the scene of calendar. here is my code …
[lua]
–
– scenetemplate.lua
–
local composer = require( “composer” )
local scene = composer.newScene()
local widget = require( “widget” )
local constants = require(“constants”)
local date
local month
local year
function scene:create( event )
local sceneGroup = self.view
local widget = require( “widget” )
– Create two tables to hold data for days and years
local days = {}
local years = {}
– Populate the “days” table
for d = 1, 31 do
days[d] = d
end
– Populate the “years” table
for y = 1, 48 do
years[y] = 2000 + y
end
– Configure the picker wheel columns
local columnData =
{
– Months
{
align = “right”,
width = 140,
startIndex = 5,
labels = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }
},
– Days
{
align = “center”,
width = 60,
startIndex = 18,
labels = days
},
– Years
{
align = “center”,
width = 80,
startIndex = 10,
labels = years
}
}
– Image sheet options and declaration
local options = {
frames =
{
{ x=0, y=0, width=320, height=222 },
{ x=320, y=0, width=320, height=222 },
{ x=640, y=0, width=8, height=222 }
},
sheetContentWidth = 648,
sheetContentHeight = 222
}
local pickerWheelSheet = graphics.newImageSheet( “images/widget-pickerwheel.png”, options )
– Create the widget
local pickerWheel2 = widget.newPickerWheel
{
top = display.contentHeight*0.5-110,
columns = columnData,
sheet = pickerWheelSheet,
overlayFrame = 1,
overlayFrameWidth = 320,
overlayFrameHeight = 222,
backgroundFrame = 2,
backgroundFrameWidth = 320,
backgroundFrameHeight = 222,
separatorFrame = 3,
separatorFrameWidth = 8,
separatorFrameHeight = 222,
columnColor = { 0, 0, 0, 0 },
fontColor = { 0.4, 0.4, 0.4, 0.5 },
fontColorSelected = { 0.2, 0.6, 0.4 }
}
sceneGroup:insert(pickerWheel2)
– Get the table of current values for all columns
– This can be performed on a button tap, timer execution, or other event
local values = pickerWheel2:getValues()
– Get the value for each column in the wheel (by column index)
local currentMonth = values[1].value
local currentDay = values[2].value
local currentYear = values[3].value
print( currentMonth, currentDay, currentYear )
local function onCloseTouch( … )
– body
--local values = pickerWheel:getValues()
– Get the value for each column in the wheel (by column index)
– hour = values[1].value
– min = values[2].value
– timeMode = values[3].value
– print(hour,min,timeMode)
composer.hideOverlay( “fade”, 100 )
end
local closeBtn = display.newImageRect(“images/close.png”,40,40)
closeBtn.x = _W-15–display.contentWidth*0.9
closeBtn.y = display.contentHeight*0.5-110
closeBtn:addEventListener(“tap”,onCloseTouch)
sceneGroup:insert(closeBtn)
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if phase == “will” then
constants.prevScene = “nochange”
– Called when the scene is still off screen and is about to move on screen
elseif phase == “did” then
– Called when the scene is now on screen
–
– INSERT code here to make the scene come alive
– e.g. start timers, begin animation, play audio, etc.
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
local parent = event.parent
if event.phase == “will” then
–parent:fromCalendar(date,month,year)
elseif phase == “did” then
– Called when the scene is now off screen
end
end
function scene:destroy( event )
local sceneGroup = self.view
– Called prior to the removal of scene’s “view” (sceneGroup)
–
– INSERT code here to cleanup the scene
– e.g. remove display objects, remove touch listeners, save state, etc.
end
– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene
[/lua]
