I made a flash website with a contact form, which works perfectly in FireFox, IE and Chrome on my pc. However, in Safari I can't seem to type in any textfield; and on Android, I sowehow can only type capital letters (basically capslock is on and it won't let me change to lower case).
I'm suspecting the problem lies entirely within Flash, since sending an email does work just fine. Searching here or on Google doesn't get me to anything related.
Any tips?
Here is my code:
FormScript.as (this is an external .as file called from my main .as file)
//***All imports, vars, etc***
function submit(e:MouseEvent):void {
//Check to see if any of the fields are empty
if(yourName.text == "" || fromEmail.text == "" ||
yourSubject.text == "" ||yourMsg.text == "" ) {
valid.text = "All fields must be filled";
}
//Check if you're using a valid email address
else if(!checkEmail(fromEmail.text)) {
valid.text = "Please fill in an existing email";
}
else {
valid.text = "Verzenden..";
var emailData:String =
"name=" + yourName.text +
"&from=" + fromEmail.text +
"&subject=" + yourSubject.text +
"&msg=" + yourMsg.text;
var urlVars:URLVariables = new URLVariables(emailData);
urlVars.dataFormat = URLLoaderDataFormat.TEXT;
urlRequest.data = urlVars; varLoad.load( urlRequest );
varLoad.addEventListener(Event.COMPLETE, thankYou );
}
}
function reset(e:MouseEvent):void {
init(); //call the initial clear function
}
function checkEmail(s:String):Boolean {
//This tests for correct email address
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var r:Object = p.exec(s);
if( r == null ) {
return false;
}
return true;
}
function thankYou(e:Event):void {
var loader:URLLoader = URLLoader(e.target);
var sent = new URLVariables(loader.data).sentStatus;
if( sent == "yes" ) {
valid.text = "Thanks for your email!"; timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, msgSent);
timer.start();
}
else {
valid.text = "Something went wrong, please try again";
}
}
function msgSent(te:TimerEvent):void {
if(timer.currentCount >= 10) {
init();
timer.removeEventListener(TimerEvent.TIMER, msgSent);
}
PHP file for mail processing:
<?php
$yourName = $_POST['name'];
$fromEmail = $_POST['from'];
$yourSubject = $_POST['subject'];
$yourMsg = $_POST['msg'];
if( $yourName == true ) {
$sender = $fromEmail;
$yourEmail ="myemailaddress@example.com"; // Naturally I put in my own email address here :)
$ipAddress = $_SERVER['REMOTE_ADDR']; // This gets the user's ip Address
$emailMsg = "Van: $sender\r\n" .
"Naam: $yourName\r" .
"Subject: my site - $yourSubject\n\n" .
"$yourMsg\n\n\n\n" .
"------------------------------\r" .
"Verstuurd vanaf IP-adres $ipAddress\r" .
"X-Mailer: PHP/" . phpversion();
$return = "From: $sender\r\n";
if( mail( $yourEmail, "$yourSubject", $emailMsg, $return)) {
echo "sentStatus=yes";
}
else {
echo "sentStatus=no";
}
}
?>
EDIT:
I have managed to resolve the Android issue on this. Safari still won't let me type.
I changed the title - Original question: "Flash form on Android lets me type only capital letters/CAPS, safari won't let me type at all"
The part that probably did the trick for Android was setting the textfields to be for .htmlText
instead of .text
in the AS3 code.