PDA

View Full Version : ASP and Flash...Can't get it to work


mrand01
07-12-2003, 12:43 PM
I'm trying to learn how to use ASP and Flash together, so I'm building an extremely simple app that just transfers variables from ASP to Flash...Here is both my flash code and my ASP code...what is wrong with this.

Flash


stop();

loadVariablesNum("http://192.168.1.102/ASPFlashTest/name.asp", 0);

name_txt.text = _root.firstname + " " + _root.lastname;


ASP

<%
Dim firstname
Dim lastname

firstname = "Mike"
lastname = "Randolph"

Response.Write "firstname=Mike&lastname=Randolph"
%>

freddycodes
07-12-2003, 01:05 PM
Its apparent you are using Flash MX, your problem is you try to use the loaded variables before they have loaded. I would first suggest that you start using the LoadVars() object.


stop();
myVars = new LoadVars();
myVars.load("http://192.168.1.102/ASPFlashTest/name.asp");
myVars.onLoad = function() {
name_txt.text = this.firstname + " " + this.lastname;
}


Next in your asp script prepend the output line with a & as well.


<%
Dim firstname
Dim lastname

firstname = "Mike"
lastname = "Randolph"

Response.Write "&firstname=Mike&lastname=Randolph"
%>

mrand01
07-12-2003, 02:43 PM
awesome mang, thanks a lot

steveb1164
06-09-2004, 05:31 PM
This line works fine in MX:

Response.Write "&firstname=Mike&lastname=Randolph&"

But this returns one quotation mark:

Response.Write "&firstname=" & firstname & "&lastname=" & lastname & "&"

I also tried this:

test = "&firstname=" & firstname & "&lastname=" & lastname & "&"

Response.write test

This doesn't work either.

How can I put variable names in the Response.write and get Flash MX to take it.

Thanks.

J_Miller
06-12-2004, 11:07 PM
Hello...

You are real close to this working, but you are just a tad bit off in the syntax. Using your example above, this should do the trick for you:


<%
Dim firstname as String = "Mike"
Dim lastname as String = "Randolph"
Dim flashResults as String = "firstname=" & fistname & "&lastname=" & lastname

flashResults = Server.UrlEncode(flashResults)
Response.Write(flashResults)
%>


Anyways, hope that helps.