I thought I had the hang of storyboards.
My sequence is…
Main.lua -> splash.lua -> showRA.lua
In showRA.lua I have a couple of buttons at the top. One button has a “+” in it and when pushed goes to another scene (addRA.lua) which gets a couple of data items of the screen, checks and retrieves some data from a SQLserver database via JSON, decodes the data and puts it into a internal database. The user can add more or hit the back button which goes to showRA.lua.
ShowRA.lua when invoked, pulls all the data from the database into a small table. It creates a tableview and puts the data from the table into it.
There is an onRowTouch event that is entered
local function onRowTouch( event )
local row = event.row
local background = event.background
if event.phase == "press" then
background:setFillColor( 0, 110, 233, 255 )
print( "Pressed row: " .. row.index )
RAdetailoptions.params.id=ID[row.index - 1]
-- storyboard.gotoScene( "RAdetail" , RAdetailoptions)
storyboard.gotoScene( "RAdetail", RAdetailOptions)
end
end
The RadetailOptions look like...
local RAdetailoptions =
{
effect="slideLeft",
params =
{
id=0
}
}
(I have tried without the effect - didn't make any difference!)
on the simulator it opens the scene RAdetail.LUA
On the Iphone, the row gets turned blue (you can just see this on the simulator) and then the application appears to hang. no other events appear to be active and the RAdetail.lua scene does not come up on the screen.
RADetail is really just a stub and I am unable to ascertain if it has even been entered (Is there anyway on a device to see the print statement output?
I will post the RAdetail code - bit as I said, I am not sure if it has been entered.
[code]
–
– scenetemplate.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local widget = require (“widget”)
local id
local ShowRAoptions =
{
effect=“slideRight”,
params=
{
}
}
–
– NOTE:
– Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.
– BEGINNING OF YOUR IMPLEMENTATION
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
– CREATE display objects and add them to ‘group’ here.
– Example use-case: Restore ‘group’ from previously saved state.
local w = display.contentWidth
local h = display.contentHeight
display.setDefault(“background”,255,255,255)
– Set background to white
local toolbarGradient = graphics.newGradient( {168,181,198,255},{139,157,180,255},“down”)
local titleBar = widget.newTabBar{
gradient = toolbarGradient,
bottomfill={117,139,168,255},
height=25}
titleBar.y = (display.screenOriginY + titleBar.contentHeight * 0.5) + 20
– create embossed text to go on toolbar
local titleText = display.newEmbossedText( “Rental Agreement Details”, 0, 0, native.systemFontBold, 14 )
titleText:setReferencePoint( display.CenterReferencePoint )
titleText:setTextColor( 255 )
titleText.x = 160
titleText.y = titleBar.y
bakbutton = widget.newButton{
id = “addrabakbtn2”,
left=15,
top=50,
width = 45, height = 15,
font = “HelveticaNeue-Bold”,
yOffset=-8,
xOffset=1,
fontSize = 16,
defaultColor={168,181,198,255},
label=“Back”,
onEvent = onBackButtonEvent}
group:insert (titleBar)
group:insert(titleText)
group:insert(bakbutton)
end
onBackButtonEvent = function ( event )
local btn = event.target
if event.phase == “release” then
storyboard.gotoScene( “showra” , ShowRAoptions )
end
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
storyboard.removeScene(“showra”)
print( “1: enterScene event - RADetail” )
–id=event.params.id
–print ("Processing RA with ID = " … id)
local group = self.view
– INSERT code here (e.g. start timers, load audio, start listeners, etc.)
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local group = self.view
– INSERT code here (e.g. remove listeners, widgets, save state, etc.)
end
– END OF YOUR IMPLEMENTATION
– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )
– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )
– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )
– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )
return scene
[/code] [import]uid: 178113 topic_id: 33822 reply_id: 333822[/import]