Posts Tagged ‘convert AS2 to AS3’

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

Flash preloader, from AS2 to AS3

Thursday, February 7th, 2008

Your basic AS2 preloader:

  1. var bytetotal = this.getBytesTotal();
  2. this.onEnterFrame = function() {
  3.      var byteload = this.getBytesLoaded();
  4.      var ready = Math.round((byteload/bytetotal)*100);
  5.      someMc._xscale = ready;
  6.      if (ready == 100) {
  7.           delete this.onEnterFrame;
  8.           gotoAndPlay("2");
  9.      }
  10. };

Now in AS3

  1. this.addEventListener("enterFrame",onEnterFrame);
  2. function onEnterFrame(e:Event) {
  3. someMc.scaleX = (this.loaderInfo.bytesLoaded/this.loaderInfo.bytesTotal)*100;
  4. if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal) {
  5. gotoAndPlay(2);
  6. this.removeEventListener("enterFrame", onEnterFrame);
  7. }
  8. }

The same rules still apply to get your preloader actually starting at 0%-100%