package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLLoaderDataFormat;
import flash.net.URLVariables;
public class registration extends MovieClip {
public function registration() {
regbtn.addEventListener(MouseEvent.MOUSE_DOWN, checkForm);
MovieClip(root).reguser.text = "";
MovieClip(root).regpass.text = "";
}
function checkForm (e:MouseEvent):void {
if (MovieClip(root).reguser.text != "" && MovieClip(root).regpass.text != "") {
sendForm();
}else{
regerr.text = "Please fill in all the fields!";
}
}
function sendForm ():void {
**/*
we use the URLVariables class to store our php variables
*/**
var phpVars:URLVariables = new URLVariables();
phpVars.username = reguser.text;
phpVars.password = regpass.text;
**/*
we use the URLRequest method to get the address of our php file and attach the php vars.
*/**
var urlRequest:URLRequest = new URLRequest("http://localhost/accounts/regdb.php");
**/*
this attaches our php variables to the url request
*/**
urlRequest.data = phpVars;
**/*
the POST method is used here so we can use php's $_POST function in order to recieve our php variables.
*/**
urlRequest.method = URLRequestMethod.POST;
**/*
we use the URLLoader class to send the request URLVariables to the php file
*/**
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
**/*
runs the function once the php file has spoken to flash
*/**
urlLoader.addEventListener(Event.COMPLETE, showResultreg);
**/*
we send the request to the php file
*/**
urlLoader.load(urlRequest);
}
**/*
function to show result
*/**
function showResultreg (e:Event):void {
regerr.text = "" + e.target.data.result_message;
}
}
}**
错误 错误:错误#2101:传递给URLVariables.decode()的String必须是包含名称/值对的URL编码查询字符串。 at Error $ / throwError() 在flash.net::URLVariables/decode() 在flash.net::URLVariables() 在flash.net::URLLoader/onComplete()