Advertisement
Hendrix000007

mailsenderScript

Mar 18th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.56 KB | None | 0 0
  1. --[[
  2. KEEP IN MIND:::You have to remove mouch stuff in here including the deprecated storyboard api
  3. and the setReferencePont, but it works though
  4. --]]
  5.  
  6.  
  7. local storyboard = require( "storyboard" )
  8. storyboard.purgeOnSceneChange = true
  9. local scene = storyboard.newScene()
  10. require ( "widget" )
  11.  
  12. local _W = display.contentWidth * 0.5
  13. local _H = display.contentHeight * 0.5
  14.  
  15.  
  16. ------------------
  17. local bg, sendBox, fName, lName, post, postAddress, eMail, explText, sendBox
  18. local sendMe = {}
  19. local redirectMe = {}
  20.  
  21. local _W = display.contentWidth * 0.5
  22. local _H = display.contentHeight * 0.5
  23.  
  24.  
  25. local myTable = {fName, lName, post, postAddress, eMail }
  26. --FUNCTIONS-------
  27.  
  28. function sendMe(event)
  29.  
  30.     if event.phase == "began" then
  31.     local options = {
  32.         to = "[email protected]",
  33.         subject = "Here´s the image dude",
  34.         body = fName.text .. ", " .. lName.text .. ", " .. post.text .. ", " .. postAddress.text .. ", " .. eMail.text.. ", " .. _CryptoCode ..lName.text }
  35.         native.showPopup("mail", options )
  36.        
  37.     elseif event.phase == "ended" or event.phase == "cancelled" then
  38.         redirectMe()
  39.     end        
  40. end
  41.  
  42.  
  43. local function textListener( event )
  44.     print( "userInput event listener." )
  45. end
  46.  
  47. function redirectMe( )
  48.     fName:removeSelf()
  49.     lName:removeSelf()
  50.     post:removeSelf()
  51.     postAddress:removeSelf()
  52.     eMail:removeSelf()
  53.     storyboard.gotoScene( "main-menu" )
  54. end
  55.  
  56.  
  57. local function setFocusNilOnBg(e)
  58.     native.setKeyboardFocus ( nil )
  59. end
  60.  
  61. --------------
  62.  
  63.  
  64. -- Called when the scene's view does not exist:
  65. function scene:createScene( event )
  66.             local screenGroup = self.view
  67.        
  68.         bg = display.newImageRect ( "bg.jpg", 320, 480 )
  69.         bg:setReferencePoint(display.CenterReferencePoint)
  70.         bg.x = _W
  71.         bg.y = _H
  72.         bg.tap = setFocusNilOnBg
  73.         --------------
  74.         sendBox = display.newImageRect( "present.png", 100, 104, true )
  75.         sendBox:setReferencePoint(display.CenterReferencePoint)
  76.         sendBox.x = _W
  77.         sendBox.y = _H + 10
  78.         sendBox.touch = sendMe
  79.         ---------------
  80.         -- Create our Text Field
  81.         fName = native.newTextField( 0, 0, display.contentWidth - 40, 30 )
  82.         local hintTextFname = "Fornavn"
  83.         fName.x = _W
  84.         fName.y = 20
  85.         fName.text = hintTextFname
  86.         fName.align = "center"
  87.         -------------------
  88.         lName = native.newTextField( 0, 0, display.contentWidth - 40, 30 )
  89.         local hintTextLname = "Etternavn"
  90.         lName.x = _W
  91.         lName.y = fName.y + 40
  92.         lName.text = hintTextLname
  93.         lName.align = "center"
  94.         --------------------
  95.         post = native.newTextField( 0, 0, display.contentWidth - 40, 30 )
  96.         local hintTextPost = "Gateadresse"
  97.         post.x = _W
  98.         post.y = lName.y + 40
  99.         post.text = hintTextPost
  100.         post.align = "center"
  101.         -------------------
  102.         postAddress = native.newTextField( 0, 0, display.contentWidth - 40, 30 )
  103.         local hintTextPostname = "Postnr - sted"
  104.         postAddress.x = _W
  105.         postAddress.y = post.y + 40
  106.         postAddress.text = hintTextPostname
  107.         postAddress.align = "center"
  108.         -------------------
  109.         eMail = native.newTextField( 0, 0, display.contentWidth - 40, 30 )
  110.         local hintTextEmailname = "Epost"
  111.         eMail.x = _W
  112.         eMail.y = postAddress.y + 40
  113.         eMail.text = hintTextEmailname
  114.         eMail.align = "center"
  115.         -------------------
  116.         explText = display.newText( "Klikk på pakken for å motta en gave", display.contentWidth - 10, 30,_Gfont, 14 )
  117.         explText:setReferencePoint(display.CenterReferencePoint)
  118.         explText:setTextColor ( 255, 202, 80 )
  119.         explText.x = _W
  120.         explText.y = sendBox.y + 60
  121.         -------------------
  122.      
  123.        
  124.         local gameView = display.newGroup ( bg, sendBox, explText )
  125.         gameView.x = _W
  126.         gameView.y = _H
  127.         gameView:setReferencePoint( display.TopCenterReferencePoint )
  128.        
  129.        screenGroup:insert(gameView)
  130.  
  131. end
  132.  
  133.  
  134. -- Called immediately after scene has moved onscreen:
  135. function scene:enterScene( event )
  136.         local screenGroup = self.view
  137.         sendBox:addEventListener( "touch", sendMe )
  138.         bg:addEventListener("tap", bg)
  139.     Runtime:addEventListener( "enterFrame", sendMe )
  140. end
  141.  
  142. -- Called when scene is about to move offscreen:
  143. function scene:exitScene( event )
  144.         local screenGroup = self.view  
  145.         sendBox:removeEventListener( "tap", sendBox )
  146.         bg:removeEventListener("tap", bg)
  147.         Runtime:removeEventListener( "enterFrame", sendMe )
  148.  
  149. end
  150.  
  151. -- Called prior to the removal of scene's "view" (display group)
  152. function scene:destroyScene( event )
  153.         local screenGroup = self.view
  154.        
  155.         -----------------------------------------------------------------------------
  156.        
  157.         --      INSERT code here (e.g. remove listeners, widgets, save state, etc.)
  158.        
  159.         -----------------------------------------------------------------------------
  160.        
  161. end
  162.  
  163.  
  164.  
  165.  
  166. ---------------------------------------------------------------------------------
  167. -- END OF YOUR IMPLEMENTATION
  168. ---------------------------------------------------------------------------------
  169.  
  170. -- "createScene" event is dispatched if scene's view does not exist
  171. scene:addEventListener( "createScene", scene )
  172.  
  173.  
  174.  
  175. -- "enterScene" event is dispatched whenever scene transition has finished
  176. scene:addEventListener( "enterScene", scene )
  177.  
  178. -- "exitScene" event is dispatched before next scene's transition begins
  179. scene:addEventListener( "exitScene", scene )
  180.  
  181.  
  182. -- "destroyScene" event is dispatched before view is unloaded, which can be
  183. -- automatically unloaded in low memory situations, or explicitly via a call to
  184. -- storyboard.purgeScene() or storyboard.removeScene().
  185. scene:addEventListener( "destroyScene", scene )
  186.  
  187.  
  188. ---------------------------------------------------------------------------------
  189.  
  190.     return scene
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement