Home | Tools & Resources | Lessons | Guitar Duels | Messageboard | Member Profiles | Search | Log In

ActionScript Login

Post Reply

User Imagejeremy
8:26 pm Tuesday
November 27, 2012
Reply || Reply With Quote || Report
Mike´s gonna see this topic and be like, "What the...?" But I´m just wondering if anybody knows how to create a simple login form in Flash using ActionScript. What I have is user name and password text boxes and an login button. I want the user name text box to have focus when the form loads as well as have a click event attached to the login button so that it fires the form when the user presses enter. If I was doing this using JavaScript I woulda knocked it out in a second. It seems so complicated using Flash and AS. It might not even be possible to do this but if I figure it out I´ll post back. Unless someone else (Mike) figures it out for me.

Thanks!
User Imagejeremy
12:05 am Wednesday
November 28, 2012
Reply || Reply With Quote || Report
Apparently it´s either completely impossible or way too complicated to bring focus to a Flash object in Firefox. But I got it all working in IE and it kinda works in Firefox too, you just gotta click the main Flash object on the page and then the "internal" objects are working the way I want them too.
User Imagejeremy
4:00 am Wednesday
December 12, 2012
Reply || Reply With Quote || Report
Now I have another question... for Mike, of course... how did you make a secure login for GKN? I guess this might be a question that you might wanna answer in private. I know how to make a login but I´ve read that dudes can pull down your SWF file and decompile it to retrieve passwords from it. I´m wondering how it was done for this site. Probably some more advanced stuff was used that I haven´t learned to use yet!
User ImageMike Lindyn
10:30 am Wednesday
December 12, 2012
Reply || Reply With Quote || Report
Hi jeremy,

Sorry I did not notice this post until today.

Flash acts like a front end in the log in procedure. The real log in stuff is handled by PHP and the Database the Flash AS script simply hands the information to PHP. From there I use PHP to handle the verification and security and stuff like that. What you need is a back end language, JavaScript alone will not do it, JavaScript is a front end technology it work inside your browser you need a language that works from inside your server (Maybe I should say I don´t know of a way that you could do this with JavaScript because there might be a way I don´t know about). The technology in the back end does not have to be PHP it could be Java, Cold Fusion or Microsoft technologies like C#, or VB.NET.

As to how to do this... I think you might be better off researching the most modern methods for handling the passing of information from Flash to other languages via URLs. I used url vars to pass the information back PHP however the more recent version of Flash and Flex have stepped away from this sort of of thing although it may still be doable. In my more recent projects using this type of technology I have used AFMPHP to pass information from Flash files directly into PHP as arrays, this works great and is pretty easy once you set every thing up, but setting it up is kind of hard to understand in the beginning.

Link I found that might help:
http://www.daniweb.com/web-development/php/threads/396924/send-variables-from-as3-to-php

This is some AS3 code I pulled off a site that is somewhat close to the way I handled this situation:
var vars:URLVariables = new URLVariables();
vars.theData = data;
var req:URLRequest = new URLRequest("http://www.url.com/index.php");
req.method = URLRequestMethod.POST;
req.data = vars;

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onDataIn);
loader.load(req);

The above will send data to your php page from there you can do things like validate the user and log them in using sessions.

This is a pretty big can of worms you are opening because there are a lot of thing you have to learn like: how do you log someone in in php, how do you connect to the database, how do you get your data into the database. But if you take the time you can learn it, there is a lot to learn but really its pretty easy. There are plenty of online resources that will help you but it is not something that I could explain in one post.

I know this was not the answer you were hoping for but I hope it helped a little.
User Imagejeremy
2:10 pm Sunday
January 6, 2013
Reply || Reply With Quote || Report
Yeah. That was a cool response because I´ve actually learned and implemented exactly how you explained to do it between AS and PHP using a MySQL database. I could easily do what I´m trying to do with just HTML, PHP, and MySQL but I wanted to try something different by using Flash to build a whole site (just took a semester class on Flash). I´m not too into working with forms using Flash though. It´s so much easier to do it with HTML and PHP. But I´m gonna keep messing with Flash. Thanks, Mike!
User ImageMike Lindyn
2:58 pm Sunday
January 6, 2013
Reply || Reply With Quote || Report
Awesome, glad you were able to get this done.

I agree with you about HTML being better for forms but if you get info PHPAMF a lot of that is worked out and it gets really simple to pass that data. Just something to look into if you get bored.

Post Reply