This updated code should work. You might also look at this for some other options.
You were using the self reference, but it was not set up properly.
In any case, just using the event target in the changeColor method is enough, as shown below.
[lua]
function changeColor( event )
if (event.phase == “began”) then
event.target:setFillColor(250,0,0)
end
end
rectangles = {}
for i = 1, 25 do
rectangles[i] = display.newRect(i * 30, i * 30,20,20)
if (i < 6) then
rectangles[i].y = 100
end
if (i > 5) and (i < 11) then
rectangles[i].y = 150
end
if (i >10) and (i <16) then
rectangles[i].y = 200
end
if (i >15) and (i <21) then
rectangles[i].y = 200
end
if (i >20) and (i <26) then
rectangles[i].y = 250
end
if ( i % 5 == 0) then
rectangles[i].x = 50
elseif (i % 5 == 1) then
rectangles[i].x = 100
elseif (i % 5 == 2) then
rectangles[i].x = 150
elseif ( i % 5 == 3) then
rectangles[i].x = 200
elseif (i % 5 == 4) then
rectangles[i].x = 250
end
rectangles[i]:addEventListener( “touch”, changeColor )
end
[/lua]
Hope that helps.