Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Atari on August 30, 2004, 11:34:01 PM

Title: Flash actionscript Login
Post by: Atari on August 30, 2004, 11:34:01 PM
 Anyone,

Not sure if anyone is interested but I've been trying to get a forum login to work from flash and thought I'd post my results. This was done in flash MX . Now I went from flash 3 to MX so not sure if this will work in earlier versions of flash actionscripts  as I only know MX and higher  :P

on (release) {
    formdata = new LoadVars();
    formdata.user=username.text;
    formdata.passwrd=password.text;
    formdata.cookielength=-1;
    formdata.id="login";
    formdata.send("http://www.yoururl.com/smf/index.php?action=login2", "_self", "POST");
}

explained:

I used the LoadVars object to submit the login  information to the server. To use the LoadVars, you have to first create an instance of it.

"formData = new LoadVars();"

Then you attach the variables to the instance with the

"formdata.user=username.text;"

I made 2 input fields
1st instance named username , linetype = singleline
2nd named password, linetype = password.
And I attached all the code above to a button. And on release it submits all the data to the SMF login script.

If I understand the php part right the login is looking for the variables called user,passwrd,and the cookielength. So when the data is put together it is sent like:

user=joe&passwrd=****&cookielength=-1

Did I get that right [unknown] ?  :P

I know it works and took me a while to grasp the concept but thought I'd post up to help anyone down the road.


Title: Re: Flash actionscript Login
Post by: roboter88 on September 03, 2004, 11:23:54 AM
kewl!

I will use this :P

Additional infos for install:
Use text field names not vars.
And works atm only with iexplorer not with mozilla ( i still run smf beta 5)

now tsted also under rc1


watch @
www.beatboxbattle.org

cheers

ps. Atari i playrtcw! :)
Title: Re: Flash actionscript Login
Post by: [Unknown] on September 03, 2004, 02:06:17 PM
Quote from: roboter88 on September 03, 2004, 11:23:54 AM
And works atm only with iexplorer not with mozilla ( i still run smf beta 5)

Why so?

-[Unknown]
Title: Re: Flash actionscript Login
Post by: roboter88 on September 03, 2004, 02:17:51 PM
I have no clue under mozilla it didnt transfer the submitte data....(i tried session and cookies settings all is allowed)

It s a bug with the cookie session under mozilla and the beta 5.0 ?


l8r

with iexplorer it works.....
WITH MOZILLA ALSO°!!!!!  omg:


It was i had to clear cash for some reason...

ALL IS GOOD this FLAHS LOGIN roxxors now :) l8r

Title: Re: Flash actionscript Login
Post by: roboter88 on September 03, 2004, 07:34:40 PM
Hmmm the code produce a session error.

When i log out doesn t matter if i was online forever or limited.
Then when i click the login button inside flash without entering the right login information SMF shows me logged in but im not....
i think it has something todo with this "cookielength=-1"

I think "-" is the maximum login session time.
So when i try to login back without entering the right login infos it uses the browser cache stored cookie session...

Well it is not the cache its the cookies who are activ till session time exeeding....


I will check this later and report back


l8r
Title: Re: Flash actionscript Login
Post by: vern111 on March 02, 2008, 08:36:09 AM
here's the actionscript 3 version of the Flash Log in script. ALl that is on the screen is a log in button  and two self-descriptive text fields: username_txt and a password_txt.



login_bttn.addEventListener(MouseEvent.CLICK,sendData,false,0,true);
username_txt.border =true;
username_txt.borderColor =0x330033;
password_txt.border =true;
password_txt.borderColor =0x330033;

function sendData(event:MouseEvent):void{
var userName:String = username_txt.text;
var passwor:String= password_txt.text;
var scriptPage:String ="http://yourforumurl /index.php?action=login2";
var request:URLRequest = new URLRequest(scriptPage);
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.passwrd= password_txt.text;
variables.user = username_txt.text;
variables.cookielength= -1;
variables.id='login';
request.data = variables;

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, handleComplete,false,0,true);
loader.load(request);
}


note the  handleComplete() function is a custom function that i use to get info about the user loaded from SMF and the SSI.php file...didn't want to bother confusing this example with some custom stuff i did.
Title: Re: Flash actionscript Login
Post by: Rumbaar on March 04, 2008, 03:35:55 AM
Thx for updating vern111.