3 Replies Latest reply on Sep 9, 2006 2:54 PM by Newsgroup_User

    Gathering User Input and Storing it

    Opera Rat Level 1
      Could someone help me with step-by-step instructions on how to do this. I have search the internet and my huge director books for hours for some kind of pre-packaged instructions on getting user text input, but no luck. I have my interface set up and these are the pieces of info I want:

      User Name (limited to 30 characters)
      Login (between 6 to 15 characters)
      Password (between 6 to 15 characters)
      Password2 (must match Password)
      e-mail address (must contain an @ sign)

      I don't know if I'm supposed to use text, field, or flashTextInput component. And how do I perform the character limiting and checking for a character? I know it must be editable. How do I then gather this info with a submit button and save it to an encrypted file with the buddyAPI? And then how do I get certain elements of this data and use them in this movie or another in the program?

      Thanks in advance.
        • 1. Re: Gathering User Input and Storing it
          Level 7
          There are lots of ways of going about this, but I would do it like this:

          Use all #text members. They are, to me, the most straightforward ones
          with the most options.

          The text sprites don't need any scripts at all. Just make a "submit"
          button that does all the checking. Something like this should get you
          started:

          on mouseUp me
          if member("username").text.char.count>30 then
          alert "User name must be 30 or less characters"
          pass
          end if

          if member("login").text.char.count>15 then
          alert "Login must be 15 or less characters"
          pass
          end if

          if member("login").text.char.count<6 then
          alert "Login must be 6 or more characters"
          pass
          end if

          if member("password").text.char.count>15 then
          alert "Password must be 15 or less characters"
          pass
          end if

          if member("password").text.char.count<6 then
          alert "Password must be 6 or more characters"
          pass
          end if

          if member("password").text<>member("password2").text then
          alert "Password fields do not match"
          pass
          end if

          if not(member("email").text contains "@") then
          alert "Email field must contain an @ sign"
          pass
          end if

          baWriteIni( "info", "username", member("username").text, the
          moviePath&"settings.ini" )
          baWriteIni( "info", "login", member("login").text, the
          moviePath&"settings.ini" )
          baWriteIni( "info", "password", member("password").text, the
          moviePath&"settings.ini" )
          baWriteIni( "info", "email", member("email").text, the
          moviePath&"settings.ini" )

          baEncryptFile(the moviePath&"settings.ini","SuperSecretKey")

          go "frameThatYouGoToIfEverythingIsGood"
          end

          That's all. It will throw an error if anything is entered wrong and if
          it is all correct it will write it to the settings.ini file and encrypt
          it. To read those settings, you need to unencrypt it using the same
          SuperSecretKey and use baReadIni to get the setting out. Then you'll
          probably want to re-encrypt as soon as you finish reading it.
          • 2. Gathering User Input and Storing it
            Opera Rat Level 1
            Wow! Thanks Mike. This should be in a knowledge database. It certainly wasn't in any of my books.
            Why am I writing to the settings.ini file? What is that? Is it created by your script? It sounds like something that is generated and read automatically by a program. (And I guess that is what I'm having my program do. **beginning to feel like a real programmer**) Is this the file where I would store things like where the user left off in the program and test scores?
            • 3. Re: Gathering User Input and Storing it
              Level 7
              You can change the name to whatever you want. I just picked that name
              because it sounds official-like. You can save anything you want to it,
              using BuddyAPI's baWriteIni function is really easy (as you can see from
              my example). And you can read it back in using baReadIni which has
              similar syntax (check the BuddyAPI docs for more details).