I can’t use PHP for a few reasons, so I’m trying to get a variable FROM an ASP page… I have had success at giving a variable TO an ASP page but I can’t get the reverse to work.
Here’s my ASP code:
<html>
<body>
<%@Language="VBScript"%>
<%
dim un
un = Request.ServerVariables("LOGON_USER")
Response.Write "userName=" & un
%>
</body>
</html>
And here’s my AS3 Code:
package classes {
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
public class MyServicesScreen extends MovieClip {
private var _screenTitle:CustomText;
public function MyServicesScreen() {
_screenTitle = new CustomText("COMING SOON", 70, 0x00, false, false);
this.addChild(_screenTitle);
_screenTitle.x = 290;
_screenTitle.y = 340;
_screenTitle.selectable = false;
var request:URLRequest = new URLRequest("http://ausddwsmweb01.aus.amer.dell.com/files/Ops_Rptg/Sales_Effectiveness/Services/username_script.asp");
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try {
variables.load(request);
} catch (error:Error) {
trace("Unable to load URL: " + error);
}
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace(loader.data.toString());
}
public function kill():void {
this.removeChild(_screenTitle);
MovieClip(parent).removeChild(this);
}
}
}
And here’s the trace output:
“%3Chtml%3E%0D%0A%3Cbody%3E%0D%0A%0D%0A%0D%0AuserName=test%0D%0A%0D%0A%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E”
(I put “test” instead of my login name to maintain anonymity)
I have ALSO tried this:
trace(loader.data["userName"])
The trace output on this is “undefined”
Any help on this would be **greatly **appreciated… I’ve been google searching for days now.
**RESOLVED: **Hey folks, I just took out the <html> and <body> tags in the ASP page and voila! It worked!