13 Replies Latest reply on Apr 24, 2011 1:31 PM by kglad

    Connecting to Database, Validating Data

    saratogacoach Level 1



      I'm still learning AS3 and am trying to set up validating user (text box) input of 2 items (name and password) by checking with an SQL Server Database on my website.


      I have the ASP page set up using a standard request/response.write script. It works I've tested the ASP, and it works. The ASP receives the 2 variables, hopefully each in a name-value pair, and checks with the DB, then if the name and password received from the Flash SWF match a name and password in the DB, sends back a "YES" and, if not, sends back a "NO".


      I'm having difficulty getting the AS3 written and working correctly. Here's what I have so far that displays errors, causes a flickering when previewed and doesn't yet work. Any suggestions, help fixing the script would be appreciated.


      nextBtn.addEventListener(MouseEvent.CLICK, nextBtnClick, false, 0, true);
      function nextBtnClick(e:MouseEvent):void {
      var input1:String = T1.text;
      var input2:String = T2.text;
      var variables:URLVariables = new URLVariables("input1=input1.value&input2=input2.value");
      var request:URLRequest = new URLRequest();
      request.url = "http://www.xyz.com/script.asp"; //once the SWF is uploaded to the site, URL will change to "/script.asp"
      request.method = URLRequestMethod.POST;
      request.data = variables;
      var loader:URLLoader = new URLLoader();
      loader.dataFormat = URLLoaderDataFormat.VARIABLES;
      loader.addEventListener(Event.COMPLETE, completeHandler);
      catch (error:Error)


      function completeHandler(event:Event):void
          var age:URLRequest = new URLRequest(event.target.data.input1.input2);
          trace(input1, input2);


      Thanks for your help.


      Kind Regards,