views:

2282

answers:

2

I have created a pretty basic Flash website for a client and am having an issue programming a Client Login feature that he would like. Currently, if I navigate to the site and click Client Login, it takes me to a login page. The way I need this to work is -- within the Flash, using ActionScript 2.0 -- have the user enter their UserID and Password and click to login, which submits POST vars to the form action of the Client Login website.

Is this possible/legal to do from a different domain? How would I go about doing this, assuming it's possible?

+3  A: 

Try this:

myVars = new LoadVars();
myVars.username = username.text;
myVars.password = pwd.text;
myVars.onLoad = function(success) {
     trace("yay!");
    else {
     trace("try again");    
    }
}
myVars.sendAndLoad("login.php", myVars, "POST");
Diodeus
A: 

So, I get "yay!" with the code provided below (yours had an error in it). However, I need to be redirected to the resulting "logged-in" page. How do I do that?

myVars = new LoadVars();
myVars.txtUserID = "some_user";
myVars.txtPassword = "some_password";
myVars.__VIEWSTATE = "dDw3MTcxMTg3ODM7dDw7bDxpPDM+O2k8NT47PjtsPHQ8cDxsPFRleHQ7PjtsPGRlbW87Pj47Oz47dDw7bDxpPDE+O2k8Mz47aTw1Pjs+O2w8dDxwPGw8VGV4dDs+O2w8YmFja2dyb3VuZC1jb2xvcjojZjZmNmY2XDtjb2xvcjojMzMzMzMzXDs7Pj47Oz47dDxwPDtwPGw8c3R5bGU7PjtsPHdpZHRoOjEwMHB4XDs7Pj4+Ozs+O3Q8cDw7cDxsPHN0eWxlOz47bDx3aWR0aDoxMDBweFw7Oz4+Pjs7Pjs+Pjs+Pjs+56k0UDxn5ED61lGLjP0fIkStm6o=";
myVars.onLoad = function(success) {
    if (success)
    {
        trace("yay!");
    } else {
        trace("try again");    
    }
}
myVars.sendAndLoad("http://www.buildertrend.net/loginFrame.aspx?builderID=35&bgcolor=%23f6f6f6&fcolor=%23333333&uwidth=100&pwidth=100", myVars, "POST");
Jeremy White
Well, if you're ending up with a NON-Flash page as a result, you are better of putting a hidden form on your parent HTML page and populating the form with JavaScript, which you can call from Flash, and submitting it.
Diodeus
Interesting hack. I'll see if that works.
Jeremy White
If you need help with the JavaScript let me know.
Diodeus
I'm pretty sure I could manage, but I've been given a different direction from my manager. So, I don't get to try it out. From my experience, though, I'm sure that would have worked. Thanks for your help.
Jeremy White