draw a line using circles: simplified??

hi,

we are trying to draw a line simply using circles in a event which is tied to enterframe.(moved)
the line draws fine initially. When we switch screens using director 1.2 and are back on the same screen, we get a strange error, when we try to insert this table in the display group(called traceScreen)
handWritten is a array which stored all circles to be drawn

attempt to call insert : a nil value

any clues whu we may be getting this error

[lua]function drawline(event)

if event.x < 260 or event.y < 590 then return end
if event.x > 495 or event.y > 800 then return end

if(event.phase==“moved”) then

handWritten[#handWritten+1] = display.newCircle(event.x,event.y,16)
handWritten[#handWritten]:setFillColor(rcolor, gcolor, bcolor)
– here is the line with error below
traceScreen:insert(handWritten[#handWritten])
print("Circles Drawn: "…#handWritten)
end[/lua]
[import]uid: 55009 topic_id: 12661 reply_id: 312661[/import]

I tried the below code and its workign fine for me…
[lua]local traceScreen = display.newGroup()
local handWritten = {}
function drawline(event)
if event.x < 260 or event.y < 590 then return end
if event.x > 495 or event.y > 800 then return end
if(event.phase==“moved”) then
handWritten[#handWritten+1] = display.newCircle(event.x,event.y,16)
handWritten[#handWritten]:setFillColor(255, 255, 255)
– here is the line with error below
traceScreen:insert(handWritten[#handWritten])
print("Circles Drawn: "…#handWritten)
end

end
Runtime:addEventListener(“touch”, drawline) [/lua] [import]uid: 71210 topic_id: 12661 reply_id: 46356[/import]

it works fine, but when we exit the screen and come back to the same screen using director it throws an error at the line where we insert the circle in the displaygroup. [import]uid: 55009 topic_id: 12661 reply_id: 46359[/import]

try giving
[lua]Runtime:removeEventListener(“touch”, drawline) [/lua]
before going to next scene…

when using Director EventListeners are not automatically removed. [import]uid: 71210 topic_id: 12661 reply_id: 46364[/import]