0 Replies Latest reply on Nov 11, 2009 7:35 AM by jssutton11

    Converting some VBScript code into Flex/ActionScript (online form manipulation)

    jssutton11

      Hi, I am revamping a program that I wrote in VBScript before that deals with accessing forms on external webpages and submitting form info through them. I am rewriting it in Flex AIR to improve it, but I can't figure out how to convert part of a code in VBScript into an ActionScript code. If you can help me at all, I'd appreciate it. Thanks.

       

      Websites such as www.usps.com/zip4 have a form on its webpage that asks for a full residential address. I'm trying to access these forms from Flex AIR and submit the values that I communicate from the AIR application to the online address form.

       

      Here is first the VBScript that performed the task and then the corresponding ActionScript I have for it so far.

       

       

      Private Sub USPSLookup(ie)
      
      Dim wshShell
      Set wshShell = WScript.CreateObject("WScript.Shell")
      
      wshShell.appactivate ("USPS - ZIP Code Lookup - Search By Address") 'Title of the window...
      
      wshShell.SendKeys "{TAB}"
      ie.Document.All.Item("address2").Value = Address(0)
      ie.Document.All.Item("city").Value = Address(1)
      ie.Document.All.Item("state").Value = Address(2)
      ie.Document.All.Item("zip5").Value = Address(3)
      wshShell.SendKeys "{ENTER}"
      
      Do While ie.Busy
      Loop
      wscript.sleep(1000)
      
      End Sub
      

       

      ActionScript segment:

       

      private function doUSPS():void
                  {
                       validateForm();
      
                          addressInfo[0] = fullname.text;
                          addressInfo[1] = address1.text;
                          addressInfo[2] = address2.text;
                          addressInfo[3] = city.text;
                          addressInfo[4] = state.text;
                          addressInfo[5] = zipcode.text;
                     
                      var urlv:URLVariables = new URLVariables();
                      urlv.q = addressInfo[1] + "," + addressInfo[2] + "," + addressInfo[3] + "," + addressInfo[4] + "," + addressInfo[5];
                      var url:URLRequest = new URLRequest();
                      url.method = URLRequestMethod.POST;
                      url.data = urlv;
                      url.url = "http://www.usps.com/zip4";
        
                      var html:HTMLLoader = new HTMLLoader();
                      html.width = browser.width;
                      html.height = browser.height;
                      html.alpha = 100;
                      html.load(url); 
      
                      var holder:UIComponent = new UIComponent();
                      holder.percentHeight = 100;
                      holder.percentWidth = 100;
                      holder.addEventListener(ResizeEvent.RESIZE, doResize, false, 0, true);
                      holder.addChild(html);
                      browser.addChild(holder);           
                  }