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 you presses the "skip" button, how can i make it do this? thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 function makeAlert() 
                local alert = native.showAlert( "Skip Level?", "Are you sure you want to skip this level?", { "Cancel", "Yes" }, onComplete )
        end
        skip:addEventListener("tap",makeAlert)

thank you so much!

views:1430 update:2011/10/2 9:44:12
corona forums © 2003-2011