Thanks Nick Sherman that is awesome, can you tell me what is wrong here, Im keep getting an error. Im eventually going to attempt to make 80 widgets with a for loop. Thank you!
[lua]local touchWidget = {}
for v = 1,3 do
--print(“onEvent”…v…" = "…tostring(onEvent[v]))
onEvent[v] = function (event)
if event.phase == “ended” then
--audio.play(s5)
if flag[v] == true then
B[v] = display.newImageRect(‘NumbersB/"…v…".png’,50,50)
B[v].x = myButton[v].x
B[v].y = myButton[v].y
screenGroup:insert(B[v])
print (‘flag[v] on’)
flag[v]=false
elseif flag[v]==false then
display.remove( B[v] )
B[v]=nil
flag[v]=true
print (‘flag[v] off’)
end
end
end
end
myButton1 = widget.newButton{
defaultFile = “NumbersA/1.png”,
left = w/2,
top = h/2,
width =w1, height = h1,
onEvent = onEvent1
}
screenGroup:insert(myButton1)
myButton2 = widget.newButton{
defaultFile = “NumbersA/2.png”,
left = w/2+70,
top = h/2,
width =w1, height = h1,
onEvent = onEvent2
}
screenGroup:insert(myButton2)
myButton3 = widget.newButton{
defaultFile = “NumbersA/3.png”,
left = w/2+140,
top = h/2,
width =w1, height = h1,
onEvent = onEvent3
}
screenGroup:insert(myButton3)
[/lua]