Copy link to clipboard
Copied
Hello,
OS: Windows 8
Flash version: Flash Pro CC version 13.1.0.226
ASP.NET platform: MS Visual Studio Professional 2012, version 11, update 4
I am working on making a 2-way connection between Flash Pro (AS3) and ASP.NET. The ASP.NET then connects to a MS Access database. I am pretty new to AS3 and ASP.NET. After searching online (thanks to some helpful souls), I have come with an AS3 code and an ASP.NET code in C#. Three variables in - PID (number), FirstName and LastName are to be sent from AS3 to ASP.NET. My ASP.NET C# code seems to be working, I sent the same variables through another webpage and it seems to receive the variables just fine. I used Fiddler2 to check the connections. The AS3 code also seems to work and it sends the right info across (by seeing it on Fiddler2), but the ASP.NET code does not seem to recognize it. I think the error may have something to do with the difference in variable type between AS3 and ASP.NET, but I'm not sure how to fix it or if it because of some other issue. Below is my AS3 and ASP.NET code, they are pretty simple.
I would really appreciate any kind of feedback/support. Thank you!
AS3 code:
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
Btn_submit.addEventListener(MouseEvent.MOUSE_UP, onClick);
function onClick(e: MouseEvent): void
{
var scriptRequest: URLRequest = new URLRequest("http://localhost/WebSite10/AS3.aspx");
var scriptLoader: URLLoader = new URLLoader();
var scriptVars: URLVariables = new URLVariables();
scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);
scriptVars.PID = PID.text;
scriptVars.FirstName = FirstName.text;
scriptVars.LastName = LastName.text;
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
scriptLoader.load(scriptRequest);
function handleLoadSuccessful($evt: Event): void {
trace("Message sent.");
}
function handleLoadError($evt: IOErrorEvent): void {
trace($evt);
}
PID.text = "";
FirstName.text = "";
LastName.text = "";
}
ASP.NET code (C#):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AS3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblPID.Text = Request.QueryString["PID"]; // lblPID is label into which the variable PID is being inputted
lblFirstName.Text = Request.QueryString["FirstName"]; // lblFirstName is label into which the variable FirstName is being inputted
lblLastName.Text = Request.QueryString["LastName"]; // lblLastName is label into which the variable LastName is being inputted
}
}
In your C# you have Request.QueryString - that would only work if you're sending query parameters - aka GET. You are using POST in Flash though... either change to GET or change to request.form
Copy link to clipboard
Copied
In your C# you have Request.QueryString - that would only work if you're sending query parameters - aka GET. You are using POST in Flash though... either change to GET or change to request.form
Find more inspiration, events, and resources on the new Adobe Community
Explore Now