Dear Fellow Developers,
For unknown reasons, my storyboard buttons (next page button, previous page button) do not work any more after I use scroll widget. I have now attached my code below. I have spent days trying to find bugs, unfortunately, I haven’t got any luck. Please help. Thank you.
Regards,
Henry
module (…, package.seeall)------------
local p1 = storyboard.newScene (“p1”)-----------
function p1:createScene( event )---------------
local localGroup = self.view
local scrollView = widget.newScrollView{
top = 0, left = 0,
width = display.contentWidth, height = display.contentHeight,
bgColor = { 255, 255, 255, 0 }, --Un-Comment this to set the background color of the scrollView.
–scrollBarColor = { 255, 0, 128 }, --Un-Comment this to set the scrollBar to a custom color.
–hideScrollBar = true, --Un-Comment this to hide the scrollBar
–listener = scrollListener
}
local lotsOfText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur imperdiet consectetur euismod. Phasellus non ipsum vel eros vestibulum consequat. Integer convallis quam id urna tristique eu viverra risus eleifend.\n\nAenean suscipit placerat venenatis. Pellentesque faucibus venenatis eleifend. Nam lorem felis, rhoncus vel rutrum quis, tincidunt in sapien. Proin eu elit tortor. Nam ut mauris pellentesque justo vulputate convallis eu vitae metus. Praesent mauris eros, hendrerit ac convallis vel, cursus quis sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque fermentum, dui in vehicula dapibus, lorem nisi placerat turpis, quis gravida elit lectus eget nibh. Mauris molestie auctor facilisis.\n\nCurabitur lorem mi, molestie eget tincidunt quis, blandit a libero. Cras a lorem sed purus gravida rhoncus. Cras vel risus dolor, at accumsan nisi. Morbi sit amet sem purus, ut tempor mauris.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur imperdiet consectetur euismod. Phasellus non ipsum vel eros vestibulum consequat. Integer convallis quam id urna tristique eu viverra risus eleifend.\n\nAenean suscipit placerat venenatis. Pellentesque faucibus venenatis eleifend. Nam lorem felis, rhoncus vel rutrum quis, tincidunt in sapien. Proin eu elit tortor. Nam ut mauris pellentesque justo vulputate convallis eu vitae metus. Praesent mauris eros, hendrerit ac convallis vel, cursus quis sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque fermentum, dui in vehicula dapibus, lorem nisi placerat turpis, quis gravida elit lectus eget nibh. Mauris molestie auctor facilisis.\n\nCurabitur lorem mi, molestie eget tincidunt quis, blandit a libero. Cras a lorem sed purus gravida rhoncus. Cras vel risus dolor, at accumsan nisi. Morbi sit amet sem purus, ut tempor mauris. "
local lotsOfTextObject = display.newText(lotsOfText, 0, 0,display.contentWidth-100,0, “Helvetica”, 27, display.contentWidth*.05)
lotsOfTextObject:setTextColor( 0 )
lotsOfTextObject:setReferencePoint( display.TopCenterReferencePoint )
lotsOfTextObject.x = display.contentCenterX
lotsOfTextObject.y = 0
scrollView:insert(lotsOfTextObject)
local background = display.newRect(localGroup,0, 0, display.contentWidth, display.contentHeight)
background:setFillColor(255, 255, 255)
local backbutton = display.newImage (“Graphics/backbutton.png”)
backbutton.x = 390
backbutton.y = 1150
localGroup:insert(backbutton)
local function pressBack (event)
if event.phase == “ended” then
require (“toc”)
storyboard.gotoScene( “toc” )
storyboard.removeScene( “p1” )
if (scrollView) then
scrollView:removeSelf();
scrollView = nil
end
end
end
backbutton:addEventListener (“tap”, pressBack)
local narrator = display.newImage (“Graphics/audio.png”)
narrator.x = 620
narrator.y = 1000
localGroup:insert(narrator)
–>This places the "narrator"button
local stop = display.newImage (“Graphics/stop.png”)
stop.x = 390
stop.y = 1000
localGroup:insert(stop)
–> This places the “stop” button
audio01 = audio.loadStream(“Audio/1.mp3”)
function narrator:tap(event)
audio.play(audio01)
end
function stop: tap(event)
audio.stop()
end
narrator:addEventListener (“tap”, narrator)
stop: addEventListener (“tap”, stop)
backbutton:addEventListener (“tap”, stop)
local nextpagebutton = display.newImage (“Graphics/nextpage.png”)
nextpagebutton.x = 620
nextpagebutton.y = 1150
localGroup:insert(nextpagebutton)
local function pressNextpagebutton (event)
if event.phase == “ended” then
require (“p2”)
storyboard.gotoScene (“p2”)
storyboard.removeScene( “p1” )
if (scrollView) then
scrollView:removeSelf();
scrollView = nil
end
end
end
nextpagebutton:addEventListener (“tap”, pressNextpagebutton)
nextpagebutton:addEventListener (“tap”, stop)
local previouspagebutton = display.newImage (“Graphics/previouspage.png”)
previouspagebutton.x = 170
previouspagebutton.y = 1150
localGroup:insert(previouspagebutton)
local function pressPreviouspagebutton (event)
if event.phase == “ended” then
– director:changeScene (“p02”)
require (“toc”)
storyboard.gotoScene (“toc”)
storyboard.removeScene( “p1” )
if (scrollView) then
scrollView:removeSelf();
scrollView = nil
end
end
end
previouspagebutton:addEventListener (“tap”, pressPreviouspagebutton)
previouspagebutton:addEventListener (“tap”, stop)
local switchbutton = display.newImage (“Graphics/switch.png”)
switchbutton.x = 170
switchbutton.y = 1000
localGroup:insert(switchbutton)
local function pressSwitchbutton (event)
if event.phase == “ended” then
require (“p1t”)
storyboard.gotoScene (“p1t”)
storyboard.removeScene( “p1” )
if (scrollView) then
scrollView:removeSelf();
scrollView = nil
end
end
end
switchbutton:addEventListener (“tap”, pressSwitchbutton)
switchbutton:addEventListener (“tap”, stop)
end
function p1:enterScene( event )
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 p1:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)
end
– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function p1:destroyScene( event )
local group = self.view
print(“scene p1 destroyed”)
p1 = nil
display.remove( scrollView )
scrollView = nil
audio.dispose(audio01)
audio01 = nil
end
– END OF YOUR IMPLEMENTATION
– “createScene” event is dispatched if scene’s view does not exist
p1:addEventListener( “createScene”, p1 )
– “enterScene” event is dispatched whenever scene transition has finished
p1:addEventListener( “enterScene”, p1 )
– “exitScene” event is dispatched whenever before next scene’s transition begins
p1:addEventListener( “exitScene”, p1 )
– “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().
p1:addEventListener( “destroyScene”, p1 )[code]
[import]uid: 150748 topic_id: 33289 reply_id: 333289[/import]