go to scene when press a button

you can get it here

https://www.dropbox.com/s/tc62g0ily5pm619/RSS%20Testing.zip?dl=0

It showed the splash screen, cleared it and then I saw a screen with 10 B&W buttons with green circular backgrounds. This seems to be working without me changing anything.

Are you not seeing this?

is it taking you to the feed page ?

you can see there is feed,lua files on the project numbered from 1 to 10, for me I want the buttons from 1 to 10 to open the feed pages from 1 to 10, and also I want to put a back button to take me back to the main screen 

could you please help me with that ???

I thought you were saying it was not going to the scene with the 10 buttons.

Your buttons are not working because you’re trying to call functions that don’t exist.  For instance:

 local button2 = widget.newButton({ id = "wed\_scn", defaultFile = "wed\_btn.png", overFile = "wed\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -210, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen3 }) sceneGroup:insert(button2) button2.x = display.contentCenterX - 1 button2.y = display.contentCenterY - 245

You try to call myApp.showScreen3, but that function doesn’t exist anywhere.  BTW:  You don’t need the myApp. on the front of those function calls in this scene.  It was something needed  to make the tabBar work in main.lua.  Just define them as:

local function showScreen3() ... end

above the scene:create() function in menu.lua.

Rob

What is the code in the function myApp.showScreen2()?

Rob

I’m using the corona sample business app, if you mean the code inside myapp, the code is

local M = {}

return M

this is the whole code 


–to move to scene

local function onBtnPress( event )

  if event.target.id == 1 then

    storyboard.gotoScene ( “storyboard-” … event.target.id )

end

end

local composer = require( “composer” )

local scene = composer.newScene()

local widget = require( “widget” )

local widgetExtras = require(“widget-extras”)

local myApp = require( “myapp” )

widget.setTheme(myApp.theme)

local titleText

local locationtxt

local views = {}

local function ignoreTouch( event )

return true

end

function scene:create( event )

local sceneGroup = self.view

local background = display.newRect(0,0,display.contentWidth, display.contentHeight)

background:setFillColor( 0.95, 0.95, 0.95 )

    background.x = display.contentCenterX

    background.y = display.contentCenterY

sceneGroup:insert(background)

background:addEventListener(“touch”, ignoreTouch)

    local navBar = widget.newNavigationBar({

        title = “تجربة تطبيق اخباري”,

        backgroundColor = { 0.5, 0.5, 0.5 },

        titleColor = {1, 1, 1},

        font = “HelveticaNeue”

    })

    sceneGroup:insert(navBar)

    local button1 = widget.newButton({

        id = “gen_scn”,

        defaultFile = “gen_btn.png”, 

        overFile = “gen_btn.png”,

    width = 90,

    height = 90,

    label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

    labelYOffset = -1, 

    font = myApp.font,

    fontSize = 18,

    emboss = false,

    onRelease = myApp.showScreen2

    })

    sceneGroup:insert(button1)

    button1.x = display.contentCenterX + 110

    button1.y = display.contentCenterY - 160

    local button2 = widget.newButton({

        id = “wed_scn”,

        defaultFile = “wed_btn.png”, 

        overFile = “wed_btn.png”,

    width = 90,

    height = 90,

    label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

    labelYOffset = -210, 

    font = myApp.font,

    fontSize = 18,

    emboss = false,

    onRelease = myApp.showScreen3

    })

    sceneGroup:insert(button2)

    button2.x = display.contentCenterX - 1

    button2.y = display.contentCenterY - 245

    local button3 = widget.newButton({

        id = “deth_scn”,

        defaultFile = “deth_btn.png”, 

        overFile = “deth_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

    labelYOffset = -200, 

    font = myApp.font,

    fontSize = 18,

    emboss = false,

    onRelease = myApp.showScreen4

    })

    sceneGroup:insert(button3)

    button3.x = display.contentCenterX + 110

    button3.y = display.contentCenterY - 130

    local button4 = widget.newButton({

        id = “born_scn”,

        defaultFile = “born_btn.png”, 

        overFile = “born_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

    labelYOffset = -360, 

    font = myApp.font,

    fontSize = 18,

    emboss = false,

    onRelease = myApp.showScreen5

    })

    sceneGroup:insert(button4)

    button4.x = display.contentCenterX - 110

    button4.y = display.contentCenterY - 320

     local button5 = widget.newButton({

        id = “relig_scn”,

        defaultFile = “relig_btn.png”, 

        overFile = “relig_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

        labelYOffset = -160, 

        font = myApp.font,

        fontSize = 18,

        emboss = false,

        onRelease = myApp.showScreen6

    })

    sceneGroup:insert(button5)

    button5.x = display.contentCenterX - 110

    button5.y = display.contentCenterY - 110

    local button6 = widget.newButton({

        id = “women_scn”,

        defaultFile = “women_btn.png”, 

        overFile = “women_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

        labelYOffset = -160, 

        font = myApp.font,

        fontSize = 18,

        emboss = false,

        onRelease = myApp.showScreen7

    })

    sceneGroup:insert(button6)

    button6.x = display.contentCenterX - 1

    button6.y = display.contentCenterY - 110

    local button7 = widget.newButton({

        id = “mix_scn”,

        defaultFile = “mix_btn.png”, 

        overFile = “mix_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

        labelYOffset = -70, 

        font = myApp.font,

        fontSize = 18,

        emboss = false,

        onRelease = myApp.showScreen8

    })

    sceneGroup:insert(button7)

    button7.x = display.contentCenterX + 110

    button7.y = display.contentCenterY + 50

    local button8 = widget.newButton({

        id = “ads_scn”,

        defaultFile = “ads_btn.png”, 

        overFile = “ads_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

        labelYOffset = -70, 

        font = myApp.font,

        fontSize = 18,

        emboss = false,

        onRelease = myApp.showScreen9

    })

    sceneGroup:insert(button8)

    button8.x = display.contentCenterX - 3

    button8.y = display.contentCenterY + 50

    local button9 = widget.newButton({

        id = “contact_scn”,

        defaultFile = “contact_btn.png”, 

        overFile = “contact_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

        labelYOffset = 60, 

        font = myApp.font,

        fontSize = 18,

        emboss = false,

        onRelease = myApp.showScreen10

    })

    sceneGroup:insert(button9)

    button9.x = display.contentCenterX - 110

    button9.y = display.contentCenterY + 80

     local button10 = widget.newButton({

        id = “about_scn”,

        defaultFile = “about_btn.png”, 

        overFile = “about_btn.png”,

        width = 90,

        height = 90,

        label = “”,

        labelColor = { 

            default = { 0.90, 0.60, 0.34 }, 

            over = { 0.79, 0.48, 0.30 } 

        },

        labelYOffset = 60, 

        font = myApp.font,

        fontSize = 18,

        emboss = false,

        onRelease = myApp.showScreen11

    })

    sceneGroup:insert(button10)

    button10.x = display.contentCenterX + 0

    button10.y = display.contentCenterY + 185

end

function scene:show( event )

local sceneGroup = self.view

end

function scene:hide( event )

local sceneGroup = self.view

storyboard.gotoScene ( “storyboard-list”)

– Clean up native objects

end

function scene:destroy( event )

local sceneGroup = self.view

end

scene:addEventListener( “create”, scene )

scene:addEventListener( “show”, scene )

scene:addEventListener( “hide”, scene )

scene:addEventListener( “destroy”, scene )

return scene

Oh I recognized where the code originated. But that doesn’t mean you’ve not changed it since downloading.  In main.lua functions were defined to handle the button presses:

In fact that block of code is:

function myApp.showScreen2(event) myApp.tabBar:setSelected(2) local options = { feedName = "corona.rss", -- feedURL = "http://www.coronalabs.com/feed/atom/", feedURL = "http://www.ems1.com/ems-rss-feeds/news.xml", icons = "fixed", displayMode = "webpage", pageTitle = "Corona Labs" } composer.removeHidden() composer.gotoScene("feed", {time=250, effect="crossFade", params = options}) return true end

in the original.  (Also, when posting code please click on the <> in forum formatting bar above where you type and paste your code into the window that pops up).

So back to my question, what is the content of the myApp.showScreen2() function?

function myApp.showScreen1() &nbsp; &nbsp; myApp.button4Press = showScreen2 &nbsp; &nbsp; composer.removeHidden() &nbsp; &nbsp; composer.gotoScene("menu", {time=250, effect="crossFade"}) &nbsp; &nbsp; return true end

this is what inside that function 

I did not know if I wrote it well ??

Is this not working?  The code looks like what I would expect it to be.

NO 

it is not working, when I press the button, it is not taking me to the specified scene 

I am using an icons on the buttons 

Is anything happening?

Are there any messages in the terminal/console window that the simulator opens in the background?

Can you put some print statements in the various functions to make sure they are getting called correctly?

Rob

NO 

nothing is happening and written on the console 

Can you post some more code.

Rob

this is in the main.lua 

--------------------------------------------------------------------------------------- --display.setStatusBar( display.HiddenStatusBar ) -- -- load in composer -- local composer = require ( "composer" ) local widget = require( "widget" ) local json = require( "json" ) local myApp = require( "myapp" )&nbsp; if (display.pixelHeight/display.pixelWidth) \> 1.5 then &nbsp; &nbsp; myApp.isTall = true end if display.contentWidth \> 320 then &nbsp; &nbsp; myApp.is\_iPad = true end -- -- turn on debugging -- local debugMode = true -- -- this little snippet will make a copy of the print function -- and now will only print if debugMode is true -- quick way to clean up your logging for production -- reallyPrint = print function print(...) &nbsp; &nbsp; if debugMode then &nbsp; &nbsp; &nbsp; &nbsp; reallyPrint(unpack(arg)) &nbsp; &nbsp; end end math.randomseed(os.time()) -- -- Load our fonts and define our styles -- local tabBarBackgroundFile = "images/tabBarBg7.png" local tabBarLeft = "images/tabBar\_tabSelectedLeft7.png" local tabBarMiddle = "images/tabBar\_tabSelectedMiddle7.png" local tabBarRight = "images/tabBar\_tabSelectedRight7.png" myApp.topBarBg = "images/topBarBg7.png" local iconInfo = { &nbsp; &nbsp; width = 40, &nbsp; &nbsp; height = 40, &nbsp; &nbsp; numFrames = 20, &nbsp; &nbsp; sheetContentWidth = 200, &nbsp; &nbsp; sheetContentHeight = 160 } myApp.icons = graphics.newImageSheet("images/ios7icons.png", iconInfo) if system.getInfo("platformName") == "Android" then &nbsp; &nbsp; myApp.theme = "widget\_theme\_android" &nbsp; &nbsp; myApp.font = "Droid Sans" &nbsp; &nbsp; myApp.fontBold = "Droid Sans Bold" &nbsp; &nbsp; myApp.fontItalic = "Droid Sans" &nbsp; &nbsp; myApp.fontBoldItalic = "Droid Sans Bold" &nbsp; &nbsp; myApp.topBarBg = "images/topBarBg7.png" else &nbsp; &nbsp; myApp.theme = "widget\_theme\_ios7" &nbsp; &nbsp; local coronaBuild = system.getInfo("build") &nbsp; &nbsp; if tonumber(coronaBuild:sub(6,12)) \< 1206 then &nbsp; &nbsp; &nbsp; &nbsp; myApp.theme = "widget\_theme\_ios" &nbsp; &nbsp; end &nbsp; &nbsp; myApp.font = "HelveticaNeue-Light" &nbsp; &nbsp; myApp.fontBold = "HelveticaNeue" &nbsp; &nbsp; myApp.fontItalic = "HelveticaNeue-LightItalic" &nbsp; &nbsp; myApp.fontBoldItalic = "Helvetica-BoldItalic" end widget.setTheme(myApp.theme) -- -- These next functions, showScreen1 - showScreen4 are the functions that are -- triggered when the user taps the buttons in the bottom tabView -- -- -- These should be pretty straight forward. &nbsp;You need to provide a local file&nbsp; -- name to download the feed to (feedName), the URL to fetch from, displayMode -- can be either "podcaset" or "webpage", which tells the module how to handle -- the story body. -- pageTitle is the thing that shows at the top of the list view. -- -- -- The variable "composer" is just a Lua table that is returned from the&nbsp; -- require("composer" above. &nbsp;As such, I can freely add members/attributes/entries -- to the table. &nbsp;By using this technique, I can quickly pass data between&nbsp; -- composer scenes. &nbsp;It's like making them global without the penalties of&nbsp; -- making them global. &nbsp;There is one catch... Corona Labs could come along and&nbsp; -- add theor own "displayMode" member (or any of them) later and trump yours -- but the risk is minmal. -- function myApp.showScreen1() &nbsp; &nbsp; myApp.button4Press = showScreen2 &nbsp; &nbsp; composer.removeHidden() &nbsp; &nbsp; composer.gotoScene("menu", {time=250, effect="crossFade"}) &nbsp; &nbsp; return true end -- -- build the top bar which is a tab bar without buttons -- --Create a group that contains the screens beneath the tab bar -- each button has a label which shows on the buttons. &nbsp;You need an up-state -- graphic (non-selected buttons, a down-state button (the currently selected -- tab) selected will mark which button starts as active, and the onPress calls -- the function above to actually show each tab. ----------------- local background = display.newRect(0,0, display.contentWidth, display.contentHeight) background:setFillColor( 1, 1, 1 ) background.x = display.contentCenterX background.y = display.contentCenterY local logo = display.newImageRect("Splash.png", 320, 480) logo.x = display.contentCenterX logo.y = display.contentCenterY local title = display.newText("Business Sample App", 0, 0, myApp.fontBold, 28) title:setFillColor( 0, 0, 0 ) title.x = display.contentCenterX title.y = display.contentHeight - 64 -- -- now make the first tab active.align -- local function closeSplash() &nbsp; &nbsp; display.remove(title) &nbsp; &nbsp; title = nil &nbsp; &nbsp; display.remove(logo) &nbsp; &nbsp; logo = nil &nbsp; &nbsp; display.remove(background) &nbsp; &nbsp; background = nil &nbsp; &nbsp; myApp.showScreen1() end timer.performWithDelay(1500, closeSplash)

this is in the menu.lua 

--------------------------------------------------------------------------------------- local composer = require( "composer" ) local scene = composer.newScene() local widget = require( "widget" ) local widgetExtras = require("widget-extras") local myApp = require( "myapp" ) widget.setTheme(myApp.theme) local titleText local locationtxt local views = {} local function ignoreTouch( event ) return true end function scene:create( event ) local sceneGroup = self.view local background = display.newRect(0,0,display.contentWidth, display.contentHeight) background:setFillColor( 0.95, 0.95, 0.95 ) background.x = display.contentCenterX background.y = display.contentCenterY sceneGroup:insert(background) background:addEventListener("touch", ignoreTouch) local navBar = widget.newNavigationBar({ title = "تجربة تطبيق اخباري", backgroundColor = { 0.5, 0.5, 0.5 }, titleColor = {1, 1, 1}, font = "default" --HelveticaNeue }) sceneGroup:insert(navBar) local button1 = widget.newButton({ id = "gen\_scn", defaultFile = "gen\_btn.png", overFile = "gen\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -1, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen3 }) sceneGroup:insert(button1) button1.x = display.contentCenterX + 110 button1.y = display.contentCenterY - 160 local button2 = widget.newButton({ id = "wed\_scn", defaultFile = "wed\_btn.png", overFile = "wed\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -210, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen3 }) sceneGroup:insert(button2) button2.x = display.contentCenterX - 1 button2.y = display.contentCenterY - 245 local button3 = widget.newButton({ id = "deth\_scn", defaultFile = "deth\_btn.png", overFile = "deth\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -200, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen4 }) sceneGroup:insert(button3) button3.x = display.contentCenterX + 110 button3.y = display.contentCenterY - 130 local button4 = widget.newButton({ id = "born\_scn", defaultFile = "born\_btn.png", overFile = "born\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -360, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen5 }) sceneGroup:insert(button4) button4.x = display.contentCenterX - 110 button4.y = display.contentCenterY - 320 local button5 = widget.newButton({ id = "relig\_scn", defaultFile = "relig\_btn.png", overFile = "relig\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -160, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen6 }) sceneGroup:insert(button5) button5.x = display.contentCenterX - 110 button5.y = display.contentCenterY - 110 local button6 = widget.newButton({ id = "women\_scn", defaultFile = "women\_btn.png", overFile = "women\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -160, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen7 }) sceneGroup:insert(button6) button6.x = display.contentCenterX - 1 button6.y = display.contentCenterY - 110 local button7 = widget.newButton({ id = "mix\_scn", defaultFile = "mix\_btn.png", overFile = "mix\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -70, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen8 }) sceneGroup:insert(button7) button7.x = display.contentCenterX + 110 button7.y = display.contentCenterY + 50 local button8 = widget.newButton({ id = "ads\_scn", defaultFile = "ads\_btn.png", overFile = "ads\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = -70, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen9 }) sceneGroup:insert(button8) button8.x = display.contentCenterX - 3 button8.y = display.contentCenterY + 50 local button9 = widget.newButton({ id = "contact\_scn", defaultFile = "contact\_btn.png", overFile = "contact\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = 60, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen10 }) sceneGroup:insert(button9) button9.x = display.contentCenterX - 110 button9.y = display.contentCenterY + 80 local button10 = widget.newButton({ id = "about\_scn", defaultFile = "about\_btn.png", overFile = "about\_btn.png", width = 90, height = 90, label = "", labelColor = { default = { 0.90, 0.60, 0.34 }, over = { 0.79, 0.48, 0.30 } }, labelYOffset = 60, font = myApp.font, fontSize = 18, emboss = false, onRelease = myApp.showScreen11 }) sceneGroup:insert(button10) button10.x = display.contentCenterX + 0 button10.y = display.contentCenterY + 185 end function scene:show( event ) local sceneGroup = self.view end function scene:hide( event ) local sceneGroup = self.view storyboard.gotoScene ( "storyboard-list") -- -- Clean up native objects -- end function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

I see two things potentially wrong.  First in menu.lua in the hide function, you make a call to storyboard. You should a) not call goto scene from the hide() event. You get this event because this scene is being hidden.  b) its a storyboard call, not a composer call. Simply remove the line.

Next, menu.lua is missing all the functions to handle the buttons.  I don’t know if this is causing errors or not.  There should be something in the console log.

You can put in some print statements and try to watch the code execute.

Rob

if you mean this code 

storyboard.gotoScene ( "storyboard-list")

this I wrote it as a test only and I removed it now,

the console is showing nothing when I press on the buttons,

could you please help me for how to write the good code so when I press the button it takes me to the specified scene ??

PLEASE I NEED  YOUR HELP

Are you on a Mac or a PC?

i’m using both on my projects 

Where are you actively developing this?  Because there is an OS-X bug that sometimes causes the terminal window to not print things.  On the Mac try running “Corona Terminal” instead of “Corona Simulator” and see if messages show up?

Rob

it is the same it is showing nothing when I press a button 

if I but an image on a button is that affecting the button ?