Passing variables from a dynamically created textinput in AS2?
I have a contact form in my flash file with name/email/message fields which a user can fill out and then click send, which passes these to a php script which then emails the information that they entered. This works fine when the text inputs are manually placed on the stage and all the information is passed to the php script and emailed to me. I am just updating it so the textinputs are created via AS2 so that I can style them more easily etc. This is fine however when created via script they no longer get passed to my php file. I am creating the textinput using the following code (which works fine):
var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = false;
my_fmt.font = "Arial";
my_fmt.color = inputcol;
contact_form.createTextField("contact_name", getNextHighestDepth(),112.6, 27, 174, 20);
contact_form.contact_name.wordWrap = true;
contact_form.contact_name.multiline = false;
contact_form.contact_name.border = true;
contact_form.contact_name.borderColor = inputcol;
contact_form.contact_name.type = "input";
contact_form.contact_name.setNewTextFormat(my_fmt);
contact_form.contact_name.text = "";
FYI I am creating this outside the movieclip containing the form (called contact_form) and then adding it into that mc specifically because I thought this may be necessary as doing it within the mc itself (using this.createTextField....) didn't work, however both seem to have the same effect.
I am then doing various checks on the input box contents (to make sure it's not empty etc), this also works fine and gives me the relevant error if it is empty so it's accessing it correctly. I then use the following code to submit the variables and check_status checks the success/failure of the php script and alerts the user accordingly:
loadVariables("http://www.makeaportfolio.com/send_email.php?flashmo=" + random(1000), this, "POST");
message_status.text = "sending....";
var interval_id = setInte开发者_开发技巧rval(check_status, 400);
This works fine however does not pick up the value of the dynamically created text input (however does pick up all the text inputs that are manually added to the stage). I am rather confused as to why it's not picking this up and am not sure how I set it to do so, i would be immensely grateful if someone could point me in the right direction?
Thanks so much for your help as ever,
Dave
It seems you are not setting contact_name.variable. Either correcting that or forwarding contact_name.text to a member variable of this
should solve your problem.
精彩评论