Code Question~

a.tulin

New Member
Hello WDF,

I am teaching myself how to design and code in flash using templates.

I have added several additional fields in the contact section of the site for the user to fill in, such that this info can be sent to the owner of the site.

My questions is how do I change the names of the fields so they show up correctly in the email?

For example. The site came with three fields and they are titled, "name", "email address" and "message". I designed it such that the user is filling in different info like there birthday, shoe size, etc and when the site owner receives the email, I want to make sure this info is clear. (Please see picture attached)

I have located the aforementioned titles in the Main.as file, however when I change them and upload to the server, the original titles still show up in the email. Do I need to check out and edit the "contact.php" file also?

Any ideas?

I think this is the code that I must edit in order for the new fields to show up in the email generated through the site is below.

Thanks in advance.
Alex


public function contactFormAction(form:MovieClip,clearButton:MovieClip,sendButton:MovieClip,maxTitleText:Number):void {

var iForm:Number = 0;
clearButton.fieldTxt.thisText.htmlText = websiteXML.pages.titlePage[linkPage].texts.contatcForm.button.text[0].text();
sendButton.fieldTxt.thisText.htmlText = websiteXML.pages.titlePage[linkPage].texts.contatcForm.button.text[1].text();

clearButton.fieldTxt.thisText.autoSize = TextFieldAutoSize.LEFT;
sendButton.fieldTxt.thisText.autoSize = TextFieldAutoSize.LEFT;
clearButton.addEventListener( MouseEvent.CLICK, clearClick );



while (iForm <= maxTitleText) {
//form['NameformItem_' + iForm].htmlText = websiteXML.pages.titlePage[linkPage].texts.contatcForm.titleTextForm.textForm[iForm].text();

// form['NameformItem_' + iForm].restrict = '^a-z';
// form['NameformItem_' + iForm].autoSize = TextFieldAutoSize.LEFT;
form['formItem_' + iForm].addEventListener( FocusEvent.FOCUS_IN, onFormItemFocusIn);
form['formItem_' + iForm].addEventListener( FocusEvent.FOCUS_OUT, onFormItemFocusOut);
form['formItem_' + iForm].htmlText = websiteXML.pages.titlePage[linkPage].texts.contatcForm.titleTextForm.textForm[iForm].text();

formItems[ iForm ] = websiteXML.pages.titlePage[linkPage].texts.contatcForm.titleTextForm.textForm[iForm].text();
//trace(formItems);
iForm++;
}

xmlFormLoader= new URLLoader();
xmlFormLoader.addEventListener(Event.COMPLETE, showformXML);
xmlFormLoader.load(new URLRequest(titleFormXML));
XML.ignoreWhitespace = true;

function showformXML(e:Event) {
confXML = new XML(xmlFormLoader.data);
sendButton.addEventListener( MouseEvent.CLICK, sendClick );

}

/////////////////////////////SENDCLICK/////////////////////////////////////////////
function sendClick( event:MouseEvent ):Boolean {

form.formMessage.text = "";

if (stage.displayState==StageDisplayState.FULL_SCREEN) {

//stage.displayState=StageDisplayState.NORMAL;
form.formMessage.text = confXML.exitFullScreenMsg;
}


var iForm:uint = 0;
var notValidated:Boolean = false;
while (iForm <= maxTitleText) {

var error:String = validateFields(iForm);
if (error != ""){
form.formMessage.text = error;
notValidated = true;
break;
}
iForm++;
}


if ( confXML && !notValidated ) {
form.formMessage.text=confXML.formProcessingText;
var formData:Array = new Array();

formData.push( { key: "Full Name", value: form['formItem_' + 0].text, id : 0 } );
formData.push( { key: "Mail", value: form['formItem_' + 1].text, id : 1 } );
formData.push( { key: "Message", value: form['formItem_' + 2].text, id : 2 } );

var variables:URLVariables = new URLVariables();
var loader:URLLoader = new URLLoader();
loader.addEventListener( Event.COMPLETE, onServerResponse );
loader.addEventListener(IOErrorEvent.IO_ERROR, onServerError);

var mailFromId : Number = Number( confXML.emailFromSource );
if( mailFromId && mailFromId > 0 ) {
variables['mail_from'] = formData[ mailFromId ]['value'];
} else {
variables['mail_from'] = confXML.emailFromSource;
}
var mailSubjectId : Number = Number( confXML.subjectSource );
if(mailSubjectId && mailSubjectId > 0) {
variables['mail_subject'] = formData[ mailSubjectId ]['value'];
} else {
variables['mail_subject'] = confXML.subjectSource;
}
var mailToId : Number = Number( confXML.emailTo.valueOf().toString() );
if(mailToId && mailToId > 0) {
variables['mail_to'] = formData[mailToId]['value'];
} else {
variables['mail_to'] = confXML.emailTo;
}
variables['plain_text'] = confXML.plainText;
variables['smtp_server'] = confXML.smtpServer;
variables['smtp_port'] = confXML.smtpPort;


for( var j:Number=formData.length-1; j>=0; j-- ) {
variables[ formData[j]['key'] ] = formData[j]['value'];
}

var handlerFilePath:String = confXML.serverProcessorFileName.valueOf().toString() + '.' + confXML.serverProcessorType.valueOf().toString();
var request:URLRequest = new URLRequest( handlerFilePath );
request.method = URLRequestMethod.POST;
request.data = variables;

try
{
loader.load(request);
}
catch (error:Error)
{
trace( 'Unable to load URL' );
}
}

return true;

}

function validateFields(formItem:Number):String{

var iFormClear:Number = 0;
var oPatterns:Object = {"text":"^[a-z0-9_-]+$", "e-mail":"^([a-z0-9_\.-]+)@([a-z0-9_\.-]+)\.([a-z\.]{2,6})$", "digits":"^[0-9_-]+$"};
var oErrorMessages:Object = {"empty":confXML.validationMessages.empty, "text":confXML.validationMessages.ntext, "e-mail":confXML.validationMessages.email, "digits":confXML.validationMessages.digits};
//trace("ok");
var isRequired:String = websiteXML.pages.titlePage[linkPage].texts.contatcForm.fieldsValidationTypes.validationType[formItem].@required;


if((isRequired == "true") && (form['formItem_' + formItem].text == "")) {return oErrorMessages["empty"] ;}
else if (form['formItem_' + formItem].text != "") {

if (websiteXML.pages.titlePage[linkPage].texts.contatcForm.fieldsValidationTypes.validationType[formItem].text() != "no")
{
var pattern:RegExp = new RegExp(oPatterns[websiteXML.pages.titlePage[linkPage].texts.contatcForm.fieldsValidationTypes.validationType[formItem].text()], "i");

var txt:String = form['formItem_' + formItem].text;

var ar:Array = txt.match(pattern);

if (ar == null){

return oErrorMessages[websiteXML.pages.titlePage[linkPage].texts.contatcForm.fieldsValidationTypes.validationType[formItem].text()];

}
}
}
return "";
}
////////////////////////////////RESET///////////////////////////////////
function clearClick():void {
var iFormClear:Number=0;
while (iFormClear<=maxTitleText) {
form['formItem_' + iFormClear].htmlText = '';
form['formItem_'+iFormClear].htmlText = websiteXML.pages.titlePage[linkPage].texts.contatcForm.titleTextForm.textForm[iFormClear].text();
form.formMessage.text='';
iFormClear++;
}
}
 

Attachments

  • Picture 2.png
    Picture 2.png
    10.8 KB · Views: 51

DHDdirect

New Member
Can you zip up all the working files for this and post a link to them?

Also when you paste code in the forum please use the code tags. It's easier to read, copy, and has a better chance of displaying correctly.
 
Top