ASP not getting variables sent from Flash AS2

latoyale
latoyale used Ask the Experts™
on
I am using flash to pass variables to ASP. Unfortunately ASP is not pulling the variables. Any advice? Here is the completed Code
Flash (on a separate layer)
 
submit_btn.onRelease = function() {
emailform = new LoadVars();
emailform.var1 = var1.text;
emailform.var2 = var2.text;
emailform.sendAndLoad("form.asp",emailform,"GET");
 
};
 
ASP info
<%
Dim var1, var2
var1 = Request.QueryString("var1")
var2 = Request.QueryString("var2")
%>
<html>
<head>
<title>Test flash transfer</title>
 
</head>
<body>
<%
Response.Write("Display Var 1" & var1 & "!<br />")
Response.Write("Display Var 2" & var2 & "!<br />")
%>
 
</body>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bob ButcheriSeries Engineer

Commented:
I think when you are "GET"ing a form you need to access the data with request.form not request.querystring.
Bob ButcheriSeries Engineer

Commented:
Sorry, I think I got that backwards with the "Get".
Bob ButcheriSeries Engineer

Commented:
For the heck of it, did you try and retrieve with REQUEST.FORM("var1")?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I tried it and it still didn't work.  The flash doesn't seem to be passing the variables.
Bob ButcheriSeries Engineer

Commented:
Just for the heck of it change:
emailform.sendAndLoad("form.asp",emailform,"GET");
to
emailform.sendAndLoad("form.asp",emailform,"POST");

are you any values with the request.form?

Author

Commented:
No I am not getting any values in ASP.  Heck, I'm not even sure how flash is supposed to put the variable info into ASP.  :(

OK first, is there a way to create a function in flash  that will check whether the variables are sent to ASP?

Author

Commented:
Or at least output the variable data?  that way I will know that flash is working correctly.

Author

Commented:
After debugging the code, I confirmed that flash is sending the query string correctly:

URL 'http://www.###.com/LaToya/form.asp?var2=why&var1=hello'


*** I think I figured out the issue... when running the flash in the browser I get the following message:
Adobe Flash Player has stopped a potentially unsafe operation

The following local application or network:
form.swf

is trying to communicate with this Internet-enabled location:

www.##.com  (I am using ## because I am not at liberty to put up the url)

To let this application communicate with the Internet, click Settings.  You must restart the application after changing your settings

Commented:
Where did I see this post...  :)

Why is there a mention of www.##.com when your ActionScript does not have that information???

If you are testing locally, copy your HTML, SWF and ASP files to your localhost and test from there, or push everything to your host and test from there...  Don't try to combine those because that probably is why you are getting that error message where your HTML/SWF is in one server and your ASP code is in another server...

CyanBlue
Bob ButcheriSeries Engineer

Commented:
good for you - I'm glad you figured it out - just delete the question if you'd like because you figured it out :)

Author

Commented:
Hello again :)

When I was testing I put in the entire url for testing.  I thought is the way it had to be done.  I will try it with just form.asp and see what happens.  When you say put everything on my host, that means put in in the same folder on the web server right?

Commented:
Yes, put them into the same directory in the web server...

I guess there was the problem from the beginning...  You did not tell us that you were using the entire URL when testing inside the Flash...  You just showed "form.asp" in the code which made us think that you were testing everything locally...  It's best to tell us such thing because that makes big difference...

It's a big deal because Flash uses different security sandbox when you test stuff inside the Flash IDE and in the web browser which applies tighter security...

Tell us what you find out...  ;)

CyanBlue

Author

Commented:
I'm sorry.  I didn't realize there was a difference with testing locally or remotely.  I thought it was like HTML; either you have local or remote urls.

I changed everything to local (asp), and nothing happens.

When I try it remotely (http:www.###.com) I get the error message.  I need to figure out how to work around the error message.


Commented:
Why don't you post the FLA, HTML and ASP code so that other people can test as well???

CyanBlue

Author

Commented:
Attached are the files...

Author

Commented:
Hmm ...  It won't take the zip file...  I have the files posted at

http://www.actionscript.org/forums/showthread.php3?p=934736&posted=1#post934736

Commented:
Well...  I did download that file and I had no idea what you want us to do with the SWF file...

CyanBlue

Author

Commented:
I just zipped everything I had including that.  The ASP and fla files should be in the zip file.  :)

Author

Commented:
New issue.... After adding some error checking I realize that the flash and ASP are OK.  The problem is the Flash player security.  It is not allowing the variables to pass because it thinks its an unsafe operation.

Does anyone know a work around this?  I am researching the "allow-access-from domain" function to attempt to fix it.

Commented:
Create this crossdomain.xml file in the root directory where your ASP script is located...

CyanBlue
<?xml version="1.0"?>
<cross-domain-policy>
	<site-control permitted-cross-domain-policies="all" />
	<allow-access-from domain="*" />
</cross-domain-policy>

Open in new window

Commented:
SOLUTION:

Hello everyone!  I got this working!!  I had to tweek the code a bit.  Just wanted to post the solution so others won't have to spend weeks like me trying to figure it out..

(FLASH)
submit_btn.onRelease = function() {
emailform = new LoadVars();
var1 = var1.text;
var2 = var2.text;
getURL("form.asp?emailform=",emailform,"GET");
};

(ASP)
<%
Dim var1, var2
var1 = Request.QueryString("var1")
var2 = Request.QueryString("var2")
%>
<html>
<head>
    <title>Test flash transfer</title>
     
</head>
<body>
<%
Response.Write("The var1 answer is " & var1 & "<br />")
Response.Write("The var2 answer is " & var2 & "<br />")
%>
 </body>
</html>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial