storyboard buttons do not work any more after using scroll widget! Help!

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

code

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]

Wow, that’s a lot of code. It’s probably good if you can enclose the code inside < code > and < /code > (without spaces) so that it’s easier to read.

Also, I don’t see the [text]return scene[/text].

And one more thing, you may really want to consider not using [text]module (…, package.seeall)[/text] as it is deprecated.

Naomi

[import]uid: 67217 topic_id: 33289 reply_id: 132252[/import]

**Thank you so much for your advice, Naomi.
Are you telling me that my problem might be solved once I add return scene?
Also,
module(…, package.seeall) has been deprecated.
What should I use now? Could you kindly give me more information?
Regards,
Henry

Dr.Henry.Chen@gmail.com
[import]uid: 150748 topic_id: 33289 reply_id: 132288[/import]**

I noticed that the following code doesn’t work once I add scroll widget in my lua file.

[code]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[code]

Unless I remove
if event.phase
end
Very strange, isn’t it?
Henry Chen

[import]uid: 150748 topic_id: 33289 reply_id: 132290[/import]

Hi Dr.Henry.Chen, about adding [text]return scene[/text], I don’t know if it would solve your problem. It just jumped out at me (because I saw another forum thread where lacking it caused a real problem for another user.)

That said, if you use the template for Storyboard API that comes bundled with Corona SDK (CoronaSDK > SampleCode > Interface > Storyboard), you can definitely do not need to use [text] module(…, package.seeall)[/text] in each of your lua module. You may also want to google the following and read up on related forum threads: ‘package seeall, deprecated’ site:coronalabs.com

It will lead you to find threads like the following (and much more):

http://developer.coronalabs.com/content/modules
http://docs.coronalabs.com/api/library/package/index.html
http://www.coronalabs.com/blog/2011/07/06/using-external-modules-in-corona/
http://www.coronalabs.com/blog/2011/09/05/a-better-approach-to-external-modules/

About scrollView widget, I am yet to use it in my project, so I have no experience with it to share. Let’s hope someone else who is familiar with the scrollView widget will jump in and help you out.

Naomi
[import]uid: 67217 topic_id: 33289 reply_id: 132294[/import]

Wow, that’s a lot of code. It’s probably good if you can enclose the code inside < code > and < /code > (without spaces) so that it’s easier to read.

Also, I don’t see the [text]return scene[/text].

And one more thing, you may really want to consider not using [text]module (…, package.seeall)[/text] as it is deprecated.

Naomi

[import]uid: 67217 topic_id: 33289 reply_id: 132252[/import]

**Thank you so much for your advice, Naomi.
Are you telling me that my problem might be solved once I add return scene?
Also,
module(…, package.seeall) has been deprecated.
What should I use now? Could you kindly give me more information?
Regards,
Henry

Dr.Henry.Chen@gmail.com
[import]uid: 150748 topic_id: 33289 reply_id: 132288[/import]**

I noticed that the following code doesn’t work once I add scroll widget in my lua file.

[code]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[code]

Unless I remove
if event.phase
end
Very strange, isn’t it?
Henry Chen

[import]uid: 150748 topic_id: 33289 reply_id: 132290[/import]

Hi Dr.Henry.Chen, about adding [text]return scene[/text], I don’t know if it would solve your problem. It just jumped out at me (because I saw another forum thread where lacking it caused a real problem for another user.)

That said, if you use the template for Storyboard API that comes bundled with Corona SDK (CoronaSDK > SampleCode > Interface > Storyboard), you can definitely do not need to use [text] module(…, package.seeall)[/text] in each of your lua module. You may also want to google the following and read up on related forum threads: ‘package seeall, deprecated’ site:coronalabs.com

It will lead you to find threads like the following (and much more):

http://developer.coronalabs.com/content/modules
http://docs.coronalabs.com/api/library/package/index.html
http://www.coronalabs.com/blog/2011/07/06/using-external-modules-in-corona/
http://www.coronalabs.com/blog/2011/09/05/a-better-approach-to-external-modules/

About scrollView widget, I am yet to use it in my project, so I have no experience with it to share. Let’s hope someone else who is familiar with the scrollView widget will jump in and help you out.

Naomi
[import]uid: 67217 topic_id: 33289 reply_id: 132294[/import]

I don’t see where you are putting your scrollView into your localGroup display group. Things that do not get put inside the scene’s view (in your case localGroup) are not managed by storyboard and sit above everything else. Since your scrollView covers the whole screen and it’s not part of a storyboard managed group, its going to block access to anything below it.

You do not need the module call at the top and you do need to return the scene variable at the end as Naomi pointed out. [import]uid: 199310 topic_id: 33289 reply_id: 132816[/import]

I don’t see where you are putting your scrollView into your localGroup display group. Things that do not get put inside the scene’s view (in your case localGroup) are not managed by storyboard and sit above everything else. Since your scrollView covers the whole screen and it’s not part of a storyboard managed group, its going to block access to anything below it.

You do not need the module call at the top and you do need to return the scene variable at the end as Naomi pointed out. [import]uid: 199310 topic_id: 33289 reply_id: 132816[/import]

Dear Rob,
Thank you so much for your advice. Yes, I will remove the module call from my lua file.
I was wondering if you could kindly show me how (and where) to put my scrollView into my localGroup display group. (Sorry, I am very new to corona sdk.)
Warm regards,
Henry
Sydney Australia
Dr.Henry.Chen@gmail.com [import]uid: 150748 topic_id: 33289 reply_id: 133034[/import]

Around line 163 add:

localGroup:insert(scrollView)

[import]uid: 199310 topic_id: 33289 reply_id: 133143[/import]

Dear Rob,
Thank you so much for your advice. Yes, I will remove the module call from my lua file.
I was wondering if you could kindly show me how (and where) to put my scrollView into my localGroup display group. (Sorry, I am very new to corona sdk.)
Warm regards,
Henry
Sydney Australia
Dr.Henry.Chen@gmail.com [import]uid: 150748 topic_id: 33289 reply_id: 133034[/import]

Around line 163 add:

localGroup:insert(scrollView)

[import]uid: 199310 topic_id: 33289 reply_id: 133143[/import]