title: Collision detection : myName nil value
body: <p>I'm trying to set up collision for my game with code from Corona SDK sample called "Collision Detection".
  I'm getting this realy strange error every time ball collides with something -</p>
  
  <blockquote>
    <p>Runtime error
            ...er 1\documents\corona projects\earthyball\level1.lua:114: attempt to concatenate field 'myName' (a nil value) stack traceback:
            [C]: ?
            ...er 1\documents\corona projects\earthyball\level1.lua:114: in function  &lt;...er 1\documents\corona prRuntime error
            ...er 1\documents\corona projects\earthyball\level1.lua:118: attempt to concatenate field 'myName' (a nil value) stack traceback:
            [C]: ?</p>
  </blockquote>
  
  <p>This is my code</p>
  
  <pre><code>    display.setStatusBar(display.HiddenStatusBar)
  
  local storyboard = require "storyboard"
  local scene = storyboard.newScene()
  
  local physics = require "physics"
  physics.start()
  
  physics.setScale( 60 )
  physics.setGravity( 0, 12 )
  
  system.setAccelerometerInterval( 100 )
  
  
  
  
  
  function scene:createScene(event)
     local screenGroup = self.view
  
  
  
  
     bkg = display.newImage("bkg.png")
      screenGroup:insert(bkg)
  
      finish = display.newImage("finishflag.png")
      finish.x = 400
      finish.y = 260
      finish.myName ="flag"
      physics.addBody(finish,"static",element)
  
     blockl1 = display.newImage("blockl1.png")
     blockl1:setReferencePoint(display.CentreReferencePoint)
     blockl1.x = 165
     blockl1.y = 230
     physics.addBody(blockl1,"static",element)
     screenGroup:insert(blockl1)
  
  
     l1block2 = display.newImage("l1block2.png")
     l1block2:setReferencePoint(display.CentreReferencePoint)
     l1block2.x = 300
     l1block2.y = 90
     physics.addBody(l1block2,"static",element)
     screenGroup:insert(l1block2)
  
     line1 = display.newImage("line1.png")
     line1:setReferencePoint(display.CentreReferencePoint)
     line1.x = 230
     line1.y = 300
     physics.addBody(line1, "static", element)
     line1.myName = "pod"
     screenGroup:insert(line1)
  
     line2 = display.newImage("line1.png")
     line2:setReferencePoint(display.CentreReferencePoint)
     line2.x = 230
     line2.y = 10
     physics.addBody(line2, "static", element)
     line2.myName = "pod2"
     screenGroup:insert(line2)
  
     line1Ver = display.newImage("lineVer.png")
     line1Ver:setReferencePoint(display.CentreReferencePoint)
     line1Ver.x = 20
     line1Ver.y = 230
     physics.addBody(line1Ver, "static", element)
     screenGroup:insert(line1Ver)
  
     line2Ver = display.newImage("lineVer.png")
     line2Ver:setReferencePoint(display.CentreReferencePoint)
     line2Ver.x = 440
     line2Ver.y = 230
     physics.addBody(line2Ver, "static", element)
     screenGroup:insert(line2Ver)
  
  
  
     ball = display.newImage("ball.png")
     ball.x = 50
     ball.y = 30
     physics.addBody(ball,"dynamic",{density=3.1, bounce=0.6, friction=0.5, radius=17})
     finish.myName ="ball"
     screenGroup:insert(ball)
  
  
  end
  
  
  
  function scene:enterScene(event)
  
  
  finish.collision = onLocalCollision
  finish:addEventListener( "collision", finish )
  
  line1.collision = onLocalCollision
  line1:addEventListener( "collision", line1 )
  
  line2.collision = onLocalCollision
  line2:addEventListener( "collision", line2 )
  
  ball.collision = onLocalCollision
  ball:addEventListener( "collision", ball )
  
  
  end
  
  
  function onLocalCollision( self, event )
      if ( event.phase == "began" ) then
  
          print( self.myName .. ": collision began with " .. event.other.myName )
  
      elseif ( event.phase == "ended" ) then
  
          print( self.myName .. ": collision ended with " .. event.other.myName )
  
      end
  end
  
  function onTilt( event )
      physics.setGravity( ( 12.5 * event.xGravity ), ( -12.5 * event.yGravity ) )
  end
  
  
  
  function scene:exitScene(event)
  
  end
  
  function scene:destroyScene(event)
  
  end
  
  
  Runtime:addEventListener( "accelerometer", onTilt )
  
  element = { friction=0.5, bounce=0.3 }
  
  
  
  scene:addEventListener("createScene",scene)
  scene:addEventListener("enterScene",scene)
  scene:addEventListener("exitScene",scene)
  scene:addEventListener("destroyScene",scene)
  
  return scene
  </code></pre>
  
  <p>Thanks for helping!</p>