Copy link to clipboard
Copied
I seem to have some issue getting infro from a database via .asp into flash, im am extremely new at this so any help would be appreciated.
flash code:
var loader : URLLoader = new URLLoader;
var urlreq:URLRequest = new URLRequest("index.asp");
var urlvars: URLVariables = new URLVariables;
var theText:TextField = new TextField();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlreq.method = URLRequestMethod.POST;
loader.load(urlreq);
theText.text = urlvars.firstName + " name."
addChild(theText);
ASP Code(connected to DB ok and can pull info into html page):
<%
Dim firstName, lastName
firstName = rs1.Fields.Item("firstName").Value
lastName = rs1.Fields.Item("lastName").Value
%>
this flash file is then embedded into the .asp page. Any help would be apprecated, thanks!
Copy link to clipboard
Copied
what are you trying to do? get data from your asp file or send data to it?
that code you showed won't do either.
Copy link to clipboard
Copied
I would wish to do both, if you have the time to explain or a site to show. If not I just would like to know how to retrieve the data from the asp page. I have tried to look on multiple sites but they weren't very helpful. Thank you for your help.
Copy link to clipboard
Copied
to send data:
var loader : URLLoader = new URLLoader;
var urlreq:URLRequest = new URLRequest("index.asp");
var urlvars: URLVariables = new URLVariables;
urlvars.firstname = sometextfield.text;
urlvars.lastname = someothertextfield.text;
urlreq.data=urlvars
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlreq.method = URLRequestMethod.POST;
loader.load(urlreq);
to receive data:
var loader : URLLoader = new URLLoader;
loader.addEventListener(Event.COMPLETE,completeF);
var urlreq:URLRequest = new URLRequest("index.asp");
var urlvars: URLVariables = new URLVariables;
urlvars.firstname = sometextfield.text;
urlvars.lastname = someothertextfield.text;
urlreq.data=urlvars
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlreq.method = URLRequestMethod.POST;
loader.load(urlreq);
function competeF(e:Event):void{
trace(loader.data);
}
///
and your asp file should use something like the following to return data:
Response.Write(firstName);
Response.Write(lastName);
Copy link to clipboard
Copied
Thank you kglad, very helpful, however I think I may have an issue with my asp page, I tried the response.write my variable, and then tried to trace it out into my flash, however Im not getting any info back. When I trace loader.data I get a very long string of information. Here is how I have my asp set up.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/DustinsDB.asp" -->
<%
Dim rs1__MMColParam
rs1__MMColParam = "1"
If (Request.QueryString("ID") <> "") Then
rs1__MMColParam = Request.QueryString("ID")
End If
%>
<%
Dim rs1
Dim rs1_cmd
Dim rs1_numRows
Set rs1_cmd = Server.CreateObject ("ADODB.Command")
rs1_cmd.ActiveConnection = MM_DustinsDB_STRING
rs1_cmd.CommandText = "SELECT * FROM NAMES WHERE ID = ? ORDER BY firstName ASC"
rs1_cmd.Prepared = true
rs1_cmd.Parameters.Append rs1_cmd.CreateParameter("param1", 5, 1, -1, rs1__MMColParam) ' adDouble
Set rs1 = rs1_cmd.Execute
rs1_numRows = 0
%>
<%
Dim firstName, lastName
firstName = rs1.Fields.Item("firstName").Value
lastName = rs1.Fields.Item("lastName").Value
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Flash DB Test</title>
</head>
<body>
<%Response.Write(firstName)%>
</body>
</html>
<%
rs1.Close()
Set rs1 = Nothing
%>
Again, I apprecate all your help. Thanks!
Copy link to clipboard
Copied
that looks like a page that's supposed to be displayed in a browser, not one used to send and receive data from flash.
Copy link to clipboard
Copied
Do you happen to know where I can find a resource where I can see how the asp page is supposed to look I removed the HTML data from the page and just left the asp database connection and variables with response.write outputting those variables but I still seem to have trouble. Thank you for your help!
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now