Skip to main content
Known Participant
November 11, 2014
Answered

reusable input text to create new output text

  • November 11, 2014
  • 1 reply
  • 801 views

Hi Im trying to use A movie clip with four input textfields nested inside the input textfield ( Customer Name, Delivery, Phone Number, Address), after a user presses the save button, I want to save the text to my output textfields(Customer Name ,Delivery, Phone Number,Address). but every time I press the save button it overwrites the output textfield box. Im trying to create a new output textfield every time a user enters information into the input textfield and list that info ten to a page... any help or direction is highly appreciated!!!

This topic has been closed for replies.
Correct answer Ned Murphy

Sorry, I don't know why it paste like that. I'm trying to save the information in newText, and not have the save information changed when ps1 text is changed. because of the CHANGE event all the newText i add on stage have the same information inside. hope that makes sense... thx  for any pointers


I see that you still have the writeText function nexted within another function.  Get that out of there and give it the same level of access as the dispar function.

I think I am starting to understand what you are trying to do.  What you need to do is to make the object you are targeting only be the last tbox object that you added.  To do this you should have a variable outside of the functions ( private var newText:tbox; ) that you assign only to the most recent tbox created as it gets created... (change the line in the function to using just:   newText = new tbox(); )  Then in the writeText function you target using that variable as you have it.  That should only target the most recent tbox that you add.

Also, if you only have one set of ps1 textfields you should only assign the event listeners to them once.  If I understand what you are doing, your current code reassigns the listeners everytime you create a new tbox.  If that is the case, find somewhere else to assign them outside of the dispar function

1 reply

Ned Murphy
Legend
November 11, 2014

If you are using the same instance names for the inpout and output textfields that might be where your problem arises.  Show the code you are using for the save button event hamdler function and explain where it doesn't do what you expect.

fi500005Author
Known Participant
November 11, 2014

// this is the function that takes the input textfields offstage

public function dispar(e: MouseEvent): void {  

  ranUp += 1;

  ps1.r.text = String(ranUp);

  trace(ps1.r.text);

  bg_.NOD.ru.text = String(ranUp);

  trace("this home" + bg_.NOD.ru.text)

  bg_.NOD.fdf.text = ps1.DF.text, "" + ps1.DF.text;

  trace("fuel delivery" + ps1.DF.text);

  trace("ranUp", ranUp);

  ps1.x = 800; // input text field MC(ps1) moving offstage

   ctext();

  }

// this is my function that creates an array of the output textfields and lists them by ten, and i take my input MC (ps1) to equal my output box

public function ctext() :void {

var aTEXT: Array = new Array();

  var nTEXT: Number = 10;

  for (var i: Number = 0; i < nTEXT; i++) {

  var newText: tbox = new tbox()

  newText = new MovieClip();

  aTEXT = TEXT;

  newText.visible = false;

  newText.x =  view.gg.x + 450;

  newText.y = 88 + 0 * newText.height + 0 * 3.8;

  aTEXT.push(newText);

  addChildAt(newText, 8);

  trace(" view", view.x);

  trace(" newText", newText.x, newText.y);

switch (newText) {

  case aTEXT[0]:   

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  if (

  case aTEXT[1] (aTEXT[0]  :

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[2]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[3]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[4]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[5]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[6]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[7]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";;

  break;

  case aTEXT[8]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  case aTEXT[9]:

  newText.cn.text = ps1.CN.text, "";

  trace(TEXT.cn.text);

  newText.pn.text = ps1.PN.text, "";

  newText.ad.text = ps1.Ad.text, "";

  newText.ot.text = ps1.OT.text, "";

  break;

  }*/


}

Ned Murphy
Legend
November 11, 2014

I don't know what you are trying to do with the following two lines...

   var newText: tbox = new tbox()

   newText = new MovieClip();

I also do not know what you expect from lines like the following - what is the "" doing?

    newText.cn.text = ps1.CN.text, "";

I don't see any code relative to a Save button which is where you say the problem comes from.