Alert/Notification help

for some reason this “alert” pops up as soon as the level starts up, i only want it to pop up when somebody presses the “skip” button, how can i make it do this? thanks!

[code]
local skip = display.newImage (“skip.png”)
localGroup:insert(skip)
skip.x = 305
skip.y = 50

local function onComplete( event )
print( "index => "… event.index … " action => " … event.action )

local action = event.action
if “clicked” == event.action then
if 2 == event.index then

director:changeScene (“mainmenu”)
end
elseif “cancelled” == event.action then
end
end

local alert = native.showAlert( “Skip Level?”, “Are you sure you want to skip this level?”, { “Cancel”, “Yes” }, onComplete )
[/code] [import]uid: 10827 topic_id: 8997 reply_id: 308997[/import]

Add this to your skip button code:

skip:addEventListener("touch", skipTouched)  

And then right above where you first create the skip button, put this:

local function skipTouched(e)  
 if (e.phase = "began" then  
 local alert = native.showAlert( "Skip Level?", "Are you sure you want to skip this level?", { "Cancel", "Yes" }, onComplete )  
 end  
end  

Then move the onComplete function above that one.

So you’re moving the call to showAlert into a function that’s called when you touch the skip button.

Jay
[import]uid: 9440 topic_id: 8997 reply_id: 32819[/import]