I am trying to add eventListener for each of the balls i created in the screen. I create the balls with for loop and then assigned them to an array. It worked well so far. However, when i tried to add eventListener for each ball in the loop, it gave me phase nil value error. Can you please help me figure it out? Thanks
Here is my code:
function ballListener(event) if(phase.event=="ended") then target.event.isvisible=false end end for i=1,10,1 do a=display.newImage("ball.jpg") a.x=math.random(10,200) a.y=math.random(10,200) a:addEventListener("touch",ballListener) table.insert(balls,a) end