ui problem

i have a problem using ui.lua, any advice will be much appreciated
sorry for many different topics, but im such a noob(

[code][lua]local ui = require(“ui”)
local director = require(“director”)
function printing()
print(“wow”)
end

local button = ui.newButton
{

defaultSrc = “buttonBlue.png”, defaultX = 298, defaultY = 56,
overSrc = “buttonBlueOver.png”, overX = 298, overY = 56,
text = “Play Game”
onRelease = function()printing() end, --use a function closure to pass parameter
text = “Level 2”,
emboss = true
}
button.x = 250; button.y= 250
[/code][/lua]

terminal is pointing to onRelease,but i dont understand why its not working… [import]uid: 16142 topic_id: 11667 reply_id: 311667[/import]

[lua]local ui = require(“ui”)
local director = require(“director”)

function printing()
print(“wow”)
end

local abutton = ui.newButton {
default = “buttonBlue.png”, defaultX = 298, defaultY = 56,
over = “buttonBlueOver.png”, overX = 298, overY = 56,
text = “Play Game”,
text = “Level 2”,
emboss = true,
onRelease = printing
}
abutton.x = 250; abutton.y= 250[/lua]

I had a brief poke at this, including changing the name - I don’t like calling anything just “button” :wink:

But try it - that should work fine now :slight_smile: [import]uid: 52491 topic_id: 11667 reply_id: 42482[/import]

many thanks
ive tried to create table and later attach function to tables content… can anyone tell me whats wrong with this code? any help is appreciated of course

[code][lua]local tablesome = {
rect = display.newRect(100,100,100,100),
rect2 = display.newRect(200,200,100,100)
}

local function touchy(e)
print("!")
end

local function bla()
for i=1,#tablesome do
tablesome[i]:addEventListener(“touch”, touchy)
return tablesome
end
end
bla()

rect are displaying, but touching them not working [import]uid: 16142 topic_id: 11667 reply_id: 42494[/import]

I don’t really use tables like this but from what I know if you make a table like
[lua]local tablesome = {
rect = display.newRect(100,100,100,100),
rect2 = display.newRect(200,200,100,100)
}[/lua]
You can’t access rect, rect2 by numerical index, you have to use the pairs function to get data out

You could always just remove the rect assignments, then you shuold be able to get them via index numbers in the for loop
[lua]local tablesome = {
display.newRect(100,100,100,100),
display.newRect(200,200,100,100)
}[/lua]
Recent article that might help:
http://blog.anscamobile.com/2011/06/understanding-lua-tables-in-corona-sdk/ [import]uid: 38562 topic_id: 11667 reply_id: 42801[/import]

thanks a lot, i’ll try that) [import]uid: 16142 topic_id: 11667 reply_id: 42831[/import]