Skip navigation
Currently Being Moderated

Need help! My inputs are disapperaing in my frames.

Jan 9, 2013 12:18 PM

Tags: #action_script_3 #flash_professional #cs6

I have 3 frames and each frame has a few textinput boxes and some checkmarks that I created. Every time I click to go to next frame my inputs and check marks erase on previous frame . Is there a way to keep he text in my textinputs while I move through my frames?

 

Thanks

 
Replies
  • Currently Being Moderated
    Jan 9, 2013 12:31 PM   in reply to TACO

    You need to store the data that gets entered into variables if you want to return to a frame and restore the entries.  Create some variables in frame 1 of a layer that extends across the whole timeline for each field and assign them initial values of "" (or something similarly meaning nothing entered).  By extending it for the timeline, the variables will be available everywhere.

     

    When the playhead moves to a certain frame, you assign the values needed for inputs in that frame using the variables you created.  When someone enters a value, you need to take the value and assign it to its variable so that when you go back to that frame it is again assigning the value it currently has.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2013 4:46 PM   in reply to TACO

    If these are input textfields you can assign an event listener for when the contents change and use that to trigger saving what is entered to a variable.  The code you need to use depends on which version of Actionscript the file is using.  Which version of Actionscript are your Flash Publish Settings set up for?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2013 4:55 AM   in reply to TACO

    Assign an instance name to each input textfield for which you wish to remember entries and assign code such as that shown below.  For the code below I use textfields with instance names of "entry1" and "entry2" with similarly named variables for each...

     

    // frame1 code -  on a layer that extends the length of the populated timeline

     

    var entry1Data:String;

    var entry2Data:String; // ditto

     

    function assignData(evt:Event):void {

         this[evt.target.name+"Data"] = TextField(evt.target).text;

    }

     

     

    // frame where entry1 and entry2 textfields are located

     

    if(entry1Data != null) entry1.text = entry1Data;

    if(entry2Data != null) entry2.text = entry2Data;

     

    entry1,addEventListener(Event.CHANGE, assignData);

    entry2,addEventListener(Event.CHANGE, assignData);

     

     

    The approach coded above is slightly different from what I described earlier.  In frame 1 the variables are only declared and not assigned a value.  In this way returning to frame 1 will not change them back to an intial value, they will retain whatever value they have acquired.

     

    Also, the same function (frame 1 code) gets shared by all of the textfields, making use of the textfield name to target the variable associated with it... part of the reason for naming the variables the way they are. 

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2013 12:20 PM   in reply to TACO

    REgarding the code I showed earlier, I am noticing an error and I kinda woinder why what I provided works... but even I tested it before posting it for you and it worked... the error being I am showing commas where periods should be...

     

    entry1,addEventListener(Event.CHANGE, assignData);

    entry2,addEventListener(Event.CHANGE, assignData);

     

    should be

     

    entry1.addEventListener(Event.CHANGE, assignData);

    entry2.addEventListener(Event.CHANGE, assignData);

     

    So I guess commas can work as substitutes... though I recommend sticking with coding convention and using the dots.

     

     

    As far as the combobox and checkbox go, you could use the same approach.  You just need to store the information in a variable.  For the combobox you could store the selectedIndex and use its assigned value to automatically set it when you get to that frame.  A value of -1 is used when nothing is selected.  The checkbox has a selected property that you set true or false.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points