Close button help

So first, let me say I am a.net programmer trying to make it in a lua world. So dont judge me too harshly when I show code snippets :wink:

However, I am making an interface for this hospital app I am working on that pops up a map an a text box underneath with the directions to the hospital. (This was per request fyi). So I got that no problem, however IM trying to make a little X button down on the corner of the text box that will close the map and text box, because the are over laying the home screen of the app. How can I do this? I tried using widget buttons and touch events on an image but something is just not working.

Thanks in advance.

[code]
local function ongMap( event )
local obj = display.newImage( “closeButton.jpg” , -100, 250 )
obj.width = 25
obj.height = 25
– touch listener
function obj:touch( event )
–do something? I cant get anything to work here, tried multiple functions ----
end

– begin detecting touches
obj:addEventListener( “touch”, obj )

myMap = native.newMapView( 25, 0, 275, 180 )
myMap.mapType = “hybrid” – other mapType options are “satellite” or “hybrid”
myMap.isScrollEnabled = true
myMap.isZoomEnabled = true
myMap.isLocationUpdating = true
isVisible = myMap.isLocationVisible
myMap:setCenter( 38.354614, -81.726351 )
myMap:addMarker( 38.354614, -81.726351)
– Adding the Text Box that contains the Directions
local textBox = native.newTextBox( 22, 183, 280, 225 )
textBox.text = “Boring directions, blah…blah…blah…”
local group = display.newGroup()
group:insert( obj )

end
[/code] [import]uid: 89054 topic_id: 37163 reply_id: 67163[/import]

Something like this should get you started:

[lua]

local function ongMap( event )

local obj = display.newImageRect( “closeButton.jpg” ,25,25 )
obj.x = 60
obj.y = 300 – replaced with newImageRect for dynamic scaling (adjust X & Y as required)

obj.touch = function (event)

local btn = event.target

if event.phase == “ended” then

btn.alpha = 0 – example to show the function doing something
end
end

– begin detecting touches
obj:addEventListener( “touch”, obj.touch)

myMap = native.newMapView( 25, 0, 275, 180 )
myMap.mapType = “hybrid” – other mapType options are “satellite” or “hybrid”
myMap.isScrollEnabled = true
myMap.isZoomEnabled = true
myMap.isLocationUpdating = true
isVisible = myMap.isLocationVisible
myMap:setCenter( 38.354614, -81.726351 )
myMap:addMarker( 38.354614, -81.726351)
– Adding the Text Box that contains the Directions
local textBox = native.newTextBox( 22, 183, 280, 225 )
textBox.text = “Boring directions, blah…blah…blah…”
local group = display.newGroup()
group:insert( obj )

end

[/lua] [import]uid: 93133 topic_id: 37163 reply_id: 145411[/import]

Should I replace btn.alpha = 0 -- example to show the function doing something with something like:

 storyboard.purgeScene() 

-or even -

 scene:destroyScene( event )  
 local group = self.view  
 display.remove( button )  

Or just leave it as is?
[import]uid: 89054 topic_id: 37163 reply_id: 145417[/import]

well I tried that plus other functions to get the map to close. I just can not get the map and textbox to close. The button now closes but thats about it. [import]uid: 89054 topic_id: 37163 reply_id: 145439[/import]

Still searching. Willing to pay for help if anyone wants to jump on it. I find the lack of documentation about this disturbing. I have tried numerous functions and just can not get it to work. The map nor text box will not close. [import]uid: 89054 topic_id: 37163 reply_id: 145444[/import]

Something like this should get you started:

[lua]

local function ongMap( event )

local obj = display.newImageRect( “closeButton.jpg” ,25,25 )
obj.x = 60
obj.y = 300 – replaced with newImageRect for dynamic scaling (adjust X & Y as required)

obj.touch = function (event)

local btn = event.target

if event.phase == “ended” then

btn.alpha = 0 – example to show the function doing something
end
end

– begin detecting touches
obj:addEventListener( “touch”, obj.touch)

myMap = native.newMapView( 25, 0, 275, 180 )
myMap.mapType = “hybrid” – other mapType options are “satellite” or “hybrid”
myMap.isScrollEnabled = true
myMap.isZoomEnabled = true
myMap.isLocationUpdating = true
isVisible = myMap.isLocationVisible
myMap:setCenter( 38.354614, -81.726351 )
myMap:addMarker( 38.354614, -81.726351)
– Adding the Text Box that contains the Directions
local textBox = native.newTextBox( 22, 183, 280, 225 )
textBox.text = “Boring directions, blah…blah…blah…”
local group = display.newGroup()
group:insert( obj )

end

[/lua] [import]uid: 93133 topic_id: 37163 reply_id: 145411[/import]

Should I replace btn.alpha = 0 -- example to show the function doing something with something like:

 storyboard.purgeScene() 

-or even -

 scene:destroyScene( event )  
 local group = self.view  
 display.remove( button )  

Or just leave it as is?
[import]uid: 89054 topic_id: 37163 reply_id: 145417[/import]

well I tried that plus other functions to get the map to close. I just can not get the map and textbox to close. The button now closes but thats about it. [import]uid: 89054 topic_id: 37163 reply_id: 145439[/import]

Still searching. Willing to pay for help if anyone wants to jump on it. I find the lack of documentation about this disturbing. I have tried numerous functions and just can not get it to work. The map nor text box will not close. [import]uid: 89054 topic_id: 37163 reply_id: 145444[/import]