3 Replies Latest reply on Mar 22, 2007 10:12 AM by Newsgroup_User

    how do we make a textInput component retain its data?

    Level 7
      Hi! I inserted a textInput component and made a button for it so that when
      clicked it goes to another frame and then back again but on the return the
      textInput field is empty, how do make it retain the previous data that the
      user entered?

      Paul


        • 1. Re: how do we make a textInput component retain its data?
          Greg Dove Level 4
          My guess is that it doesn't exist on the frame that you move to so when you go back its like removing and creating a new instance of the TextInput from scratch each time you do it. A couple of approaches...
          1. Keep the instance.
          If the TextInput component is on its own layer in Flash IDE, extend the frames within that layer to include the frame that you move to after pressing the button. If you don't want it it visible and/or enabled then set its properties (visible, enabled) to false after the first button press and to true when you come back to the original frame.
          2. Use a variable to hold the value: After the button press, load a variable with the old content and when returning reassign this value to the text property of the textinput.
          • 2. Re: how do we make a textInput component retain its data?
            phil ashby Level 1
            on your button, change the code to read this (with your relevant frame/instancenames inserted)

            on(click)
            {_root.mytextboxvariable = _parent.mytextboxinstance.text
            _parent.gotoAndPlay(????)
            }

            on the frame that contains your textinput

            if (_root.mytextboxvariable != undefined)
            {mytextboxinstance.text = _root.mytextboxvariable
            }
            stop()
            • 3. Re: how do we make a textInput component retain its data?
              Level 7
              phil ashby wrote:
              > on your button, change the code to read this (with your relevant
              > frame/instancenames inserted)
              >
              > on(click)
              > {_root.mytextboxvariable = _parent.mytextboxinstance.text
              > _parent.gotoAndPlay(????)
              > }
              >
              > on the frame that contains your textinput
              >
              > if (_root.mytextboxvariable != undefined)
              > {mytextboxinstance.text = _root.mytextboxvariable
              > }
              > stop()

              HI! Thanks, I worked but I had change a few things like the on(click) to
              on(release) and the _root.mytextboxvariable to just mytextboxvariable but in
              the end it worked.

              I just need now to incorporate this idea into a larger form that I have.

              Thanks again. :)

              Paul