Copy link to clipboard
Copied
Hi,
I'm trying without success to write an AS3 script to post data to a server ASP page (which is scripted in ASP to insert the data into a DB. The ASP script does not return any data to Flash.). It is set up so that it only receives data and does not send any data back.
I've written a script which follows, but I get back a trace of "error" (see script), and when I independently check the DB, no new data that I am trying to send, is received. So, not working.
storeBtn.addEventListener(MouseEvent.CLICK,dbStore,false,0,true);
function dbStore(event:MouseEvent):void{
var g2:String;
if (selectGm == true){
g2 = "abc";
}
if (selectGf == true){
g2 = "xyz";
}
var scriptPage6:String ="https://mysite.com/ASPpage.asp";
var request6:URLRequest = new URLRequest(scriptPage6);
request6.method = URLRequestMethod.POST;
var variables6:URLVariables = new URLVariables();
variables6.aaa = data88;
variables6.bbb = data99;
variables6.name = name6;//carried over in the script from text input in an earlier frame: var name6:String = username_txt.text;
variables6.ggg = g2;
var loader6:URLLoader = new URLLoader();
loader6.dataFormat = URLLoaderDataFormat.VARIABLES;
loader6.addEventListener(Event.COMPLETE, handleComplete6);
loader6.load(request6);
//request6.data = variables6;
}
var msg:String;
function handleComplete6 (event:Event):void{
var msg = event.target.data;
if(msg=="true"){
trace("Done!");
} else{
trace("Error: "+msg);
}
}
I must be doing something wrong and would appreciate any help. I'm not sure how to send data when no return data is needed or requested?
The goal is simply to send 4 items to the ASP page (aaa, bbb, name and ggg) which can process and insert these into a DB.
Regards,
yes, it's needed. that (assigning the data property of your urlrequest) is the only way to send variables/values to your asp script.
after you fix that, eliminate your handleComplete6 function because you're not returning anything from your asp script. or, even better, have your asp script return something when it completes:
Response.Write "asp script complete."
Copy link to clipboard
Copied
storeBtn.addEventListener(MouseEvent.CLICK,dbStore,false,0,true);
function dbStore(event:MouseEvent):void{
var g2:String;
if (selectGm == true){
g2 = "abc";
}
if (selectGf == true){
g2 = "xyz";
}
var scriptPage6:String ="https://mysite.com/ASPpage.asp";
var request6:URLRequest = new URLRequest(scriptPage6);
request6.method = URLRequestMethod.POST;
var variables6:URLVariables = new URLVariables();
variables6.aaa = data88;
variables6.bbb = data99;
variables6.name = name6;//carried over in the script from text input in an earlier frame: var name6:String = username_txt.text;
variables6.ggg = g2;
var loader6:URLLoader = new URLLoader();
loader6.addEventListener(Event.COMPLETE, handleComplete6);
loader6.load(request6);
}
var msg:String;
function handleComplete6 (event:Event):void{
trace("Done!");
}
Copy link to clipboard
Copied
why is
//request6.data = variables6;
commented out??
Copy link to clipboard
Copied
Hi esdebon,
Thank you. The script executes OK. No error, traces OK.
But, I am still not geting any new data into the DB.
This is most likely a mistake I am still making with the variables I am sending. I've used this ASP page before and it works. So, I will check what I am sending.
Hi kglad,
I am trying to adapt another script that I am using in the same FLA, but that script does get a return of data. So, I renamed it from variables to variables6, to give it a unique (non-conflicting name), and in my experimenting to try tofind what would work, I probably commented it out.
Is it needed?
One other way to deal with the data, if the DB will not work:
SMTP Mail from the SWF/APK, using ASP, that sends the data to me.
Copy link to clipboard
Copied
yes, it's needed. that (assigning the data property of your urlrequest) is the only way to send variables/values to your asp script.
after you fix that, eliminate your handleComplete6 function because you're not returning anything from your asp script. or, even better, have your asp script return something when it completes:
Response.Write "asp script complete."
Copy link to clipboard
Copied
Thanks, kglad.
I've been slowly working my way through fixing the script. I finally got it working (which did include again using that urlrequest property). I've eliminated the handle complete function.
Seems to be working well.
Much thanks!
Copy link to clipboard
Copied
you're welcome.