[AS3]as3与php程序结合实现发送邮件的功能
[AS3]as3与php程序结合实现发送邮件的功能,AS3与PHP,as3与php交互,as3发邮件
[AS3]as3与php程序结合实现发送邮件的功能,首先在属性中绑定 Main 类
- package
- {
- import flash.display.*;
- import flash.events.*;
- import flash.text.*;
- import flash.net.*;
- public class Main extends MovieClip
- {
- public function Main()
- {
- addEventListener(Event.ADDED_TO_STAGE,init);
- }
- private function init(evt:Event):void
- {
- removeEventListener(Event.ADDED_TO_STAGE,init);
- trace("My Document Class has been created correctly");
- form_mc.send_btn.addEventListener(MouseEvent.MOUSE_DOWN,checkFields);
- }
- private function checkFields(evt:MouseEvent):void
- {
- if(form_mc.name_txt.text!=""&&form_mc.email_txt.text!=""&&form_mc.message_txt.text!="")
- sendMessage();
- }
- private function sendMessage():void
- {
- var variables:URLVariables=new URLVariables();
- variables.name=form_mc.name_txt.text;
- variables.email=form_mc.email_txt.text;
- variables.message=form_mc.message_txt.text;
- var request:URLRequest=new URLRequest();
- request.url='email.php';
- request.method=URLRequestMethod.POST;
- request.data=variables;
- var loader:URLLoader=new URLLoader();
- loader.dataFormat=URLLoaderDataFormat.VARIABLES;
- loader.addEventListener(Event.COMPLETE,messageSent);
- try
- {
- form_mc.status_txt.text = 'waiting...';
- loader.load(request);
- }
- catch (error:Error)
- {
- form_mc.status_txt.text = 'Unable to load requested document.';
- }
- }
- private function messageSent(evt:Event):void
- {
- var loader:URLLoader=URLLoader(evt.target);
- var vars:URLVariables=new URLVariables(loader.data);
- if(vars.answer=="ok"){
- form_mc.name_txt.text = "";
- form_mc.email_txt.text = "";
- form_mc.message_txt.text = "";
- form_mc.status_txt.text = "CuPlayer.com提示您:邮件发送成功!";
- }else{
- form_mc.status_txt.text = "CuPlayer.com提示您:发送出错!";
- }
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...