Operate the camera with the library director. HELP!

Well I tried operating the camera of a device and no way. I’ve been simplifying the code up as much as possible and still not working. The problem is that if I ride it out and meanwhile only the code of the camera works but when I put in my app on a new page within the minimum code I get error manager.

Someone can help me??

Code: This gives me error:

[lua]module(…, package.seeall)
function new()
–creamos el grupo de imagenes
local mainGroup = display.newGroup()

–DAMOS LAS FUNCIONES Y INSTRUCCIONES PRA QUE FUNCIONE LA CAMARA

– Camera not supported on simulator.
local isXcodeSimulator = “iPhone Simulator” == system.getInfo(“model”)
if (isXcodeSimulator) then
local alert = native.showAlert( “Information”, “Camera API not available on iOS Simulator.”, { “OK”})
end

local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 128, 0, 0 )
local text = display.newText( “Tap anywhere to launch Camera”, 0, 0, nil, 16 )
text:setTextColor( 255, 255, 255 )
text.x = 0.5 * display.contentWidth
text.y = 0.5 * display.contentHeight
local sessionComplete = function(event)
local image = event.target
print( "Camera ", ( image and “returned an image” ) or “session was cancelled” )
print( "event name: " … event.name )
print( "target: " … tostring( image ) )
if image then
– center image on screen
image.x = display.contentWidth/2
image.y = display.contentHeight/2
local w = image.width
local h = image.height
print( “w,h = “… w …”,” … h )
end
end
local listener = function( event )
if media.hasSource( media.Camera ) then
media.show( media.Camera, sessionComplete )
else
native.showAlert(“Corona”, “Camera not found.”)
end
return true
end
bkgd:addEventListener( “tap”, listener )
return mainGroup
end[/lua]

ME AND THIS WORKS:

[lua]-- Camera not supported on simulator.
local isXcodeSimulator = “iPhone Simulator” == system.getInfo(“model”)
if (isXcodeSimulator) then
local alert = native.showAlert( “Information”, “Camera API not available on iOS Simulator.”, { “OK”})
end

local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 128, 0, 0 )
local text = display.newText( “Tap anywhere to launch Camera”, 0, 0, nil, 16 )
text:setTextColor( 255, 255, 255 )
text.x = 0.5 * display.contentWidth
text.y = 0.5 * display.contentHeight
local sessionComplete = function(event)
local image = event.target
print( "Camera ", ( image and “returned an image” ) or “session was cancelled” )
print( "event name: " … event.name )
print( "target: " … tostring( image ) )
if image then
– center image on screen
image.x = display.contentWidth/2
image.y = display.contentHeight/2
local w = image.width
local h = image.height
print( “w,h = “… w …”,” … h )
end
end
local listener = function( event )
if media.hasSource( media.Camera ) then
media.show( media.Camera, sessionComplete )
else
native.showAlert(“Corona”, “Camera not found.”)
end
return true
end
bkgd:addEventListener( “tap”, listener )[/lua]

All you do is take the code that is the example of the corona simulator I’ve tested and works on the phone and put it within the structure of principal. Why does not work? As I can use the camera with head?

A greeting