Posts Tagged ‘AS2-AS3 conversion’

Simple flash AS3 contact form with field validation

Thursday, April 17th, 2008

This is an example of how AS3 aint all that bad.
I simply converted an already existing AS2 contact form to AS3.
Looking at the fla you will see that not much has changed.
The only major difference is how you setup sending your vars to the php script.
An example can be seen here.

I have also attached a working fla with php script.
Download AS contact form Version 0.1

Need a custom contact form built?
Feel free to email me

First partial look at my converted AS2 to AS3 flash tracking system

Thursday, January 31st, 2008

As mentioned in my first entry I have started to mess around with AS3.
I have to say that the first couple of days i would have expected to be the hardest but not atol. As soon as i saw the new way i would normally do ‘x’ it was easy.

An example of how i would load data into flash AS2 from a php script

  1. function login() {
  2. if (txUser.text.length == 0) {
  3. txError.text = "** Username Required **";
  4. } else if (txPass.text.length == 0) {
  5. txError.text = "** Password required **";
  6. } else {
  7. mcLogin._visible = true;
  8. mcLoader._visible = true;
  9. result_lv = new LoadVars();
  10. log_lv = new LoadVars();
  11. log_lv.user = txUser.text;
  12. log_lv.pass = txPass.text;
  13. log_lv.sendAndLoad(phpPath+"login.php"+secureVar(),result_lv,"POST");
  14. result_lv.onLoad = function(success) {
  15. if (success) {
  16. if (result_lv.retval.length) {
  17. mcLoader.dataLoaded = true;
  18. } else {
  19. trace("error:"+unescape(data_lv));
  20. }
  21. }
  22. };
  23. }
  24. }

Now with AS3 we have

  1. function login() {
  2. if (txUser.text.length==0) {
  3. txError.text = "** Username Required **";
  4. } else if (txPass.text.length==0) {
  5. txError.text = "** Password required **";
  6. } else {
  7. var variables:URLVariables = new URLVariables();
  8. variables.user = txUser.text;
  9. variables.pass = txPass.text;
  10. var request:URLRequest = new URLRequest();
  11. request.url = "login.php";
  12. request.method = URLRequestMethod.POST;
  13. request.data = variables;
  14. var loader:URLLoader = new URLLoader();
  15. loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  16. loader.addEventListener(Event.COMPLETE, completeHandler);
  17. mcLoader.visible=true;
  18. mcDisable.visible=true;
  19. try {
  20. loader.load(request);
  21. } catch (error:Error) {
  22. mcDisable.visible=false;
  23. mcLoader.visible=false;
  24. txError.text="Unable to load URL";
  25. }
  26. function completeHandler(event:Event):void {
  27. restString = "Welcome back <span style="color: #990000;">"+txUser.text+"</span> You were last logged in:<span style="color: #990000;">"+event.target.data.welcomeMessage+"</span>";
  28. //
  29. gotoAndStop(2);
  30. }
  31. }
  32. }

In order to see the flash stats app working you need to first login with usename: client passowrd:client

This application is still work in progress and i am only tracking entry clicks at this point. Though work has started on registering clicks within flash. I should give a thanks to Jason at moogleMedia.com for helping me get a head start on this.