I’ve been working on a function all day, but for some reason, after I create a button widget, I cannot later call it to change its label (or do anything else to it for that matter, like remove it).
To simplify things, I’m not using my original file, but some code I typed up for testing the problem, which remains even in this simplified example:
local widget = require "widget" local function tappa(event) button:setLabel( "New Button" ) end local button = widget.newButton{label = "The Button", onRelease=tappa} button.x = display.contentCenterX button.y = display.contentCenterY
Now, what I’m expecting is that when the button is pressed, it changes the label on that button to “New Button”. What I get is a button, that when pressed, give me an “attempt to index global ‘button’ (a nil value)” error.
And yes, I know I can use event.target to change it, but the problem in my other program is that I want to change a label on Button A when Button B is pressed or remove it altogether when event C happens, so the example above is more relevant.
I’m using Notepad ++ to edit…
