Copy link to clipboard
Copied
acually am tring to send mail but am new in as3 as well , i could make it using as2 but unfortunately i build my project by as3 , they telling me tht i need PHP file to connect with , is there any tutarial or help on it ?
i approciate ur help
thnx
Copy link to clipboard
Copied
They may be wrong, so your best bet is to show how you would have done it using AS2 so that what you really want is more clear.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Flash/AS3 is still not a server-side processing language. Since your AS2 approach for the send mail interaction uses a PHP file, your AS3 approach will also need to use a PHP file. Look in the help documents for the URLVariables class. That is how you will send data to the PHP file. There is example code in the help documents that you can use as an example.
Copy link to clipboard
Copied
i almost reach but the code still not work
there is the code
import flash.net.URLRequest;
stop();
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
send_button.addEventListener(MouseEvent.CLICK, submit);
reset_button.addEventListener(MouseEvent.CLICK, reset);
var timer:Timer;
var var_load:URLLoader = new URLLoader;
var URL_request:URLRequest = new URLRequest("sendMail.php");
URL_request.method = URLRequestMethod.POST;
function submit(e:MouseEvent):void {
if ( contact_name.text == "" || contact_email.text == "" ||
contact_subject.text == "" || contact_message.text == "" ) {
message_status.text = "Please fill up all text fields.";
} else if ( !validate_email(contact_email.text) ) {
message_status.text = "Please enter the valid email address.";
} else {
message_status.text = "sending...";
var email_data:String = "name=" + contact_name.text
+ "&email=" + contact_email.text
+ "&subject=" + contact_subject.text
+ "&message=" + contact_message.text;
var URL_vars:URLVariables = new URLVariables(email_data);
URL_vars.dataFormat = URLLoaderDataFormat.TEXT;
URL_request.data = URL_vars;
var_load.load( URL_request );
var_load.addEventListener(Event.COMPLETE, receive_response );
}
}
function reset(e:MouseEvent):void {
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
}
function validate_email(s:String):Boolean {
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var r:Object = p.exec(s);
if ( r == null ) {
return false;
}
return true;
}
function receive_response(e:Event):void {
var loader:URLLoader = URLLoader(e.target);
var email_status = new URLVariables(loader.data).success;
if ( email_status == "yes" ) {
message_status.text = "Success! Your message was sent.";
timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, on_timer);
timer.start();
} else {
message_status.text = "Failed! Your message can not be sent.";
}
}
function on_timer(te:TimerEvent):void {
if ( timer.currentCount >= 10 ) {
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
timer.removeEventListener(TimerEvent.TIMER, on_timer);
}
}
Copy link to clipboard
Copied
Before I go thru your code trying to find a problem, do you get any error messages that might help focus on where the problem is?
Copy link to clipboard
Copied
no i got no error but i got only alert
"Failed! Your message can not be sent."
thnx
Copy link to clipboard
Copied
That would appear to be a response from the PHP file, so are you able to determine what in the PHP file will generate that error?
Copy link to clipboard
Copied
no really i got no idea about PHP :s
Copy link to clipboard
Copied
If it is a problem with the PHP then you may have to investigate that instead of the actionscript. But in the meantime, the only thing I can see that doesn't align with my own experience using URLVariables is the way you declare it using an argument. What you might try instead is...
var URL_vars:URLVariables = new URLVariables();
URL_vars.email_data = email_data;
Copy link to clipboard
Copied
ok thanks , would u please send me an example tht can help me ?
am on dead line
thnx Ned
Copy link to clipboard
Copied
I don't have a sendMail script nor an actionscript file that works with one, so I can't send you an example without creating one from scratch for you, which is not going to happen. If you can make both of your files available, someone may be able to deal with finding out what is wrong.... I say someone because if your Flash is a CS4 file, I don't have CS4.
I can't help with your deadline... that is out of my control. Deadlines should be based on knowledge of what needs to be done, understanding the time it takes to get it done, and the ability to do it.