mysql unescape解码_用escape函数将文本转编码存入mysql

这个博客介绍了如何使用AS3中的escape函数将文本编码后存储到MySQL数据库,并通过unescape函数解码已存储的数据。示例代码展示了在按钮点击事件中实现保存和加载操作的流程,涉及URLLoader、URLVariables和POST请求。
摘要由CSDN通过智能技术生成

as代码参考:

package {

import flash.display.MovieClip;

import flash.display.Loader;

import flash.display.LoaderInfo;

import flash.events.*;

import flash.net.*;

public class T4 extends MovieClip {

private var _at:String = "";

public function T4() {

addEventListener(Event.ADDED_TO_STAGE, addedHandler);

}

private function addedHandler(e:Event):void {

removeEventListener(Event.ADDED_TO_STAGE, addedHandler);

btnSave.addEventListener(MouseEvent.CLICK, btnSaveClickHandler);

btnLoad.addEventListener(MouseEvent.CLICK, btnLoadClickHandler);

}

private function btnSaveClickHandler(e:MouseEvent):void {

if (_at != "" ) return;

_at = "保存";

var urlLoader:URLLoader = new URLLoader();

var urlRequest:URLRequest = new URLRequest();

var vars:URLVariables = new URLVariables();

urlRequest.url = "articleSave.php";

vars.accessKey = "i am elight";

vars.uid = 1;

vars.upwd = "Elight";

vars.aid = 1;

vars.atitle = "This is a test";

vars.adata = escape(txt1.text);

urlRequest.method = URLRequestMethod.POST;

urlRequest.data = vars;

urlLoader.load(urlRequest);

urlLoader.addEventListener(Event.COMPLETE, ldCompleteHandle);

urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, ldSecurityErrorHandle);

urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ldIoErrorHandle);

}

private function btnLoadClickHandler(e:MouseEvent):void {

if (_at != "" ) return;

_at = "加载";

var urlLoader:URLLoader = new URLLoader();

var urlRequest:URLRequest = new URLRequest();

var vars:URLVariables = new URLVariables();

urlRequest.url = "articleLoad.php";

vars.accessKey = "i am elight";

vars.uid = 1;

vars.upwd = "Elight";

vars.aid = 1;

urlRequest.method = URLRequestMethod.POST;

urlRequest.data = vars;

urlLoader.load(urlRequest);

urlLoader.addEventListener(Event.COMPLETE, ldCompleteHandle);

urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, ldSecurityErrorHandle);

urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ldIoErrorHandle);

}

private function ldCompleteHandle(e:Event):void {

e.target.removeEventListener(Event.COMPLETE, ldCompleteHandle);

var loader:URLLoader = URLLoader(e.target);

var rel:*;

try {

rel = JSON.parse(loader.data);

} catch (error:Error) {

txtTs.text = _at + "数据处理失败:errorId=1";

_at = "";

return;

}

if (rel.result == "0") {

txtTs.text = _at + "数据成功!";

if (_at == "加载") {

txt2.text = unescape(rel.data);

}

} else {

txtTs.text = _at + "数据失败:" + rel.result;

}

_at = "";

}

private function ldSecurityErrorHandle(e:SecurityErrorEvent):void {

txtTs.text = "对不起,连接服务器失败(SecurityError)!";

}

private function ldIoErrorHandle(e:IOErrorEvent):void {

txtTs.text = "对不起,连接服务器失败(IoError)!";

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值